dialog.subr (f4844f65a9213b76ff8cf3cc0c9d881631c34c3a) dialog.subr (42ade6a9649e0e87c9b53035a61c8819d624480b)
1if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1
2#
3# Copyright (c) 2006-2013 Devin Teske
4# All Rights Reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 1986 unchanged lines hidden (view full) ---

1995 #
1996 [ "$USE_XDIALOG" ] && DIALOG=Xdialog
1997
1998 #
1999 # Sanity check, or die gracefully
2000 #
2001 if ! f_have $DIALOG; then
2002 unset USE_XDIALOG
1if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1
2#
3# Copyright (c) 2006-2013 Devin Teske
4# All Rights Reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 1986 unchanged lines hidden (view full) ---

1995 #
1996 [ "$USE_XDIALOG" ] && DIALOG=Xdialog
1997
1998 #
1999 # Sanity check, or die gracefully
2000 #
2001 if ! f_have $DIALOG; then
2002 unset USE_XDIALOG
2003 failed_dialog="$DIALOG"
2003 local failed_dialog="$DIALOG"
2004 DIALOG=dialog
2005 f_die 1 "$msg_no_such_file_or_directory" "$pgm" "$failed_dialog"
2006 fi
2007
2008 #
2009 # If we're already running as root but we got there by way of sudo(8)
2010 # and we have X11, we should merge the xauth(1) credentials from our
2011 # original user.

--- 4 unchanged lines hidden (view full) ---

2016 then
2017 if ! f_have xauth; then
2018 # Die gracefully, as we [likely] can't use Xdialog(1)
2019 unset USE_XDIALOG
2020 DIALOG=dialog
2021 f_die 1 "$msg_no_such_file_or_directory" "$pgm" "xauth"
2022 fi
2023 HOSTNAME=$(hostname)
2004 DIALOG=dialog
2005 f_die 1 "$msg_no_such_file_or_directory" "$pgm" "$failed_dialog"
2006 fi
2007
2008 #
2009 # If we're already running as root but we got there by way of sudo(8)
2010 # and we have X11, we should merge the xauth(1) credentials from our
2011 # original user.

--- 4 unchanged lines hidden (view full) ---

2016 then
2017 if ! f_have xauth; then
2018 # Die gracefully, as we [likely] can't use Xdialog(1)
2019 unset USE_XDIALOG
2020 DIALOG=dialog
2021 f_die 1 "$msg_no_such_file_or_directory" "$pgm" "xauth"
2022 fi
2023 HOSTNAME=$(hostname)
2024 displaynum="${DISPLAY#*:}"
2024 local displaynum="${DISPLAY#*:}"
2025 eval xauth -if \~$SUDO_USER/.Xauthority extract - \
2026 \"\$HOSTNAME/unix:\$displaynum\" \
2027 \"\$HOSTNAME:\$displaynum\" | sudo sh -c 'xauth -ivf \
2028 ~root/.Xauthority merge - > /dev/null 2>&1'
2029 fi
2030
2031 #
2032 # Probe Xdialog(1) for maximum height/width constraints, or die
2033 # gracefully
2034 #
2035 if [ "$USE_XDIALOG" ]; then
2025 eval xauth -if \~$SUDO_USER/.Xauthority extract - \
2026 \"\$HOSTNAME/unix:\$displaynum\" \
2027 \"\$HOSTNAME:\$displaynum\" | sudo sh -c 'xauth -ivf \
2028 ~root/.Xauthority merge - > /dev/null 2>&1'
2029 fi
2030
2031 #
2032 # Probe Xdialog(1) for maximum height/width constraints, or die
2033 # gracefully
2034 #
2035 if [ "$USE_XDIALOG" ]; then
2036 local maxsize
2036 if ! maxsize=$( LANG= LC_ALL= $DIALOG --print-maxsize 2>&1 )
2037 then
2038 # Xdialog(1) failed, fall back to dialog(1)
2039 unset USE_XDIALOG
2040
2041 # Display the error message produced by Xdialog(1)
2042 local height width
2043 f_dialog_buttonbox_size height width \

--- 9 unchanged lines hidden (view full) ---

2053 XDIALOG_MAXSIZE=$(
2054 set -- ${maxsize##*:}
2055
2056 height=${1%,}
2057 width=$2
2058
2059 echo $height $width
2060 )
2037 if ! maxsize=$( LANG= LC_ALL= $DIALOG --print-maxsize 2>&1 )
2038 then
2039 # Xdialog(1) failed, fall back to dialog(1)
2040 unset USE_XDIALOG
2041
2042 # Display the error message produced by Xdialog(1)
2043 local height width
2044 f_dialog_buttonbox_size height width \

--- 9 unchanged lines hidden (view full) ---

2054 XDIALOG_MAXSIZE=$(
2055 set -- ${maxsize##*:}
2056
2057 height=${1%,}
2058 width=$2
2059
2060 echo $height $width
2061 )
2061 unset maxsize
2062 fi
2063
2064 #
2065 # If using Xdialog(1), swap DIALOG_TITLE with DIALOG_BACKTITLE.
2066 # The reason for this is because many dialog(1) applications use
2067 # --backtitle for the program name (which is better suited as
2068 # --title with Xdialog(1)).
2069 #
2070 if [ "$USE_XDIALOG" ]; then
2062 fi
2063
2064 #
2065 # If using Xdialog(1), swap DIALOG_TITLE with DIALOG_BACKTITLE.
2066 # The reason for this is because many dialog(1) applications use
2067 # --backtitle for the program name (which is better suited as
2068 # --title with Xdialog(1)).
2069 #
2070 if [ "$USE_XDIALOG" ]; then
2071 _DIALOG_TITLE="$DIALOG_TITLE"
2071 local _DIALOG_TITLE="$DIALOG_TITLE"
2072 DIALOG_TITLE="$DIALOG_BACKTITLE"
2073 DIALOG_BACKTITLE="$_DIALOG_TITLE"
2072 DIALOG_TITLE="$DIALOG_BACKTITLE"
2073 DIALOG_BACKTITLE="$_DIALOG_TITLE"
2074 unset _DIALOG_TITLE
2075 fi
2076
2077 f_dprintf "f_dialog_init: dialog(1) API initialized."
2078}
2079
2080############################################################ MAIN
2081
2082#

--- 12 unchanged lines hidden ---
2074 fi
2075
2076 f_dprintf "f_dialog_init: dialog(1) API initialized."
2077}
2078
2079############################################################ MAIN
2080
2081#

--- 12 unchanged lines hidden ---