Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdconfig/share/dialog.subr
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
: ${DIALOG_TERMINAL_PASSTHRU_FD:=${TERMINAL_STDOUT_PASSTHRU:-3}} | : ${DIALOG_TERMINAL_PASSTHRU_FD:=${TERMINAL_STDOUT_PASSTHRU:-3}} | ||||
############################################################ GLOBALS | ############################################################ GLOBALS | ||||
# | # | ||||
# Default name of dialog(1) utility | # Default name of dialog(1) utility | ||||
# NOTE: This is changed to "Xdialog" by the optional `-X' argument | # NOTE: This is changed to "Xdialog" by the optional `-X' argument | ||||
# | # | ||||
DIALOG="dialog" | DIALOG="bsddialog" | ||||
# | # | ||||
# Default dialog(1) title and backtitle text | # Default dialog(1) title and backtitle text | ||||
# | # | ||||
DIALOG_TITLE="$pgm" | DIALOG_TITLE="$pgm" | ||||
DIALOG_BACKTITLE="bsdconfig" | DIALOG_BACKTITLE="bsdconfig" | ||||
# | # | ||||
Show All 11 Lines | |||||
# | # | ||||
# Exit codes for [X]dialog(1) | # Exit codes for [X]dialog(1) | ||||
# | # | ||||
DIALOG_OK=${SUCCESS:-0} | DIALOG_OK=${SUCCESS:-0} | ||||
DIALOG_CANCEL=${FAILURE:-1} | DIALOG_CANCEL=${FAILURE:-1} | ||||
DIALOG_HELP=2 | DIALOG_HELP=2 | ||||
DIALOG_EXTRA=3 | DIALOG_EXTRA=3 | ||||
if [ $DIALOG = "bsddialog" ]; then | |||||
jrtc27: Does this not break Xdialog? | |||||
asicilianoAuthorUnsubmitted Done Inline ActionsOk. I think you refer to DIALOG_ESC for Xdialog. Otherwise, please let me know how I can reproduce the fault. I'll fix it under, where -X is parsed/processed and USE_XDIALOG and $DIALOG=Xdialog are set. asiciliano: Ok. I think you refer to DIALOG_ESC for Xdialog. Otherwise, please let me know how I can… | |||||
DIALOG_ITEM_HELP=2 | |||||
DIALOG_ERROR=255 | |||||
DIALOG_ESC=5 | |||||
else | |||||
DIALOG_ITEM_HELP=4 | DIALOG_ITEM_HELP=4 | ||||
export DIALOG_ERROR=254 # sh(1) can't handle the default of `-1' | export DIALOG_ERROR=254 # sh(1) can't handle the default of `-1' | ||||
DIALOG_ESC=255 | DIALOG_ESC=255 | ||||
fi | |||||
# | # | ||||
# Default behavior is to call f_dialog_init() automatically when loaded. | # Default behavior is to call f_dialog_init() automatically when loaded. | ||||
# | # | ||||
: ${DIALOG_SELF_INITIALIZE=1} | : ${DIALOG_SELF_INITIALIZE=1} | ||||
# | # | ||||
# Default terminal size (used if/when running without a controlling terminal) | # Default terminal size (used if/when running without a controlling terminal) | ||||
▲ Show 20 Lines • Show All 2,131 Lines • ▼ Show 20 Lines | f_dialog_init() | ||||
[ "$USE_XDIALOG" ] && DIALOG=Xdialog USE_DIALOG= | [ "$USE_XDIALOG" ] && DIALOG=Xdialog USE_DIALOG= | ||||
# | # | ||||
# Sanity check, or die gracefully | # Sanity check, or die gracefully | ||||
# | # | ||||
if ! f_have $DIALOG; then | if ! f_have $DIALOG; then | ||||
unset USE_XDIALOG | unset USE_XDIALOG | ||||
local failed_dialog="$DIALOG" | local failed_dialog="$DIALOG" | ||||
DIALOG=dialog | DIALOG=bsddialog | ||||
f_die 1 "$msg_no_such_file_or_directory" "$pgm" "$failed_dialog" | f_die 1 "$msg_no_such_file_or_directory" "$pgm" "$failed_dialog" | ||||
fi | fi | ||||
# | # | ||||
# Read ~/.dialogrc (unless using Xdialog(1)) for properties | # Read ~/.dialogrc (unless using Xdialog(1)) for properties | ||||
# | # | ||||
if [ -f ~/.dialogrc -a ! "$USE_XDIALOG" ]; then | if [ -f ~/.dialogrc -a ! "$USE_XDIALOG" ]; then | ||||
eval "$( | eval "$( | ||||
Show All 15 Lines | f_dialog_init() | ||||
# | # | ||||
if [ "$USE_XDIALOG" ] && | if [ "$USE_XDIALOG" ] && | ||||
[ "$( id -u )" = "0" ] && | [ "$( id -u )" = "0" ] && | ||||
[ "$SUDO_USER" -a "$DISPLAY" ] | [ "$SUDO_USER" -a "$DISPLAY" ] | ||||
then | then | ||||
if ! f_have xauth; then | if ! f_have xauth; then | ||||
# Die gracefully, as we [likely] can't use Xdialog(1) | # Die gracefully, as we [likely] can't use Xdialog(1) | ||||
unset USE_XDIALOG | unset USE_XDIALOG | ||||
DIALOG=dialog | DIALOG=bsddialog | ||||
f_die 1 "$msg_no_such_file_or_directory" "$pgm" "xauth" | f_die 1 "$msg_no_such_file_or_directory" "$pgm" "xauth" | ||||
fi | fi | ||||
HOSTNAME=$( hostname ) | HOSTNAME=$( hostname ) | ||||
local displaynum="${DISPLAY#*:}" | local displaynum="${DISPLAY#*:}" | ||||
eval xauth -if \~$SUDO_USER/.Xauthority extract - \ | eval xauth -if \~$SUDO_USER/.Xauthority extract - \ | ||||
\"\$HOSTNAME/unix:\$displaynum\" \ | \"\$HOSTNAME/unix:\$displaynum\" \ | ||||
\"\$HOSTNAME:\$displaynum\" | sudo sh -c 'xauth -ivf \ | \"\$HOSTNAME:\$displaynum\" | sudo sh -c 'xauth -ivf \ | ||||
~root/.Xauthority merge - > /dev/null 2>&1' | ~root/.Xauthority merge - > /dev/null 2>&1' | ||||
Show All 10 Lines | if [ "$USE_XDIALOG" ]; then | ||||
then | then | ||||
# Xdialog(1) failed, fall back to dialog(1) | # Xdialog(1) failed, fall back to dialog(1) | ||||
unset USE_XDIALOG | unset USE_XDIALOG | ||||
# Display the error message produced by Xdialog(1) | # Display the error message produced by Xdialog(1) | ||||
local height width | local height width | ||||
f_dialog_buttonbox_size height width \ | f_dialog_buttonbox_size height width \ | ||||
"$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$maxsize" | "$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$maxsize" | ||||
dialog \ | dialog \ | ||||
jrtc27Unsubmitted Not Done Inline ActionsWrong dialog? jrtc27: Wrong dialog? | |||||
asicilianoAuthorUnsubmitted Done Inline ActionsOK. I' ll fix. asiciliano: OK. I' ll fix. | |||||
--title "$DIALOG_TITLE" \ | --title "$DIALOG_TITLE" \ | ||||
--backtitle "$DIALOG_BACKTITLE" \ | --backtitle "$DIALOG_BACKTITLE" \ | ||||
--ok-label "$msg_ok" \ | --ok-label "$msg_ok" \ | ||||
--msgbox "$maxsize" $height $width | --msgbox "$maxsize" $height $width | ||||
exit $FAILURE | exit $FAILURE | ||||
fi | fi | ||||
XDIALOG_MAXSIZE=$( | XDIALOG_MAXSIZE=$( | ||||
Show All 39 Lines |
Does this not break Xdialog?