Improve portion of the dialog(1) API in dialog.subr responsible for

retrieving stored data (for the --menu, --calendar, --timebox, --checklist,
and --radiolist widgets).

When we (Ron McDowell and I) developed the first version of bsdconfig, it
used temporary files to store responses from dialog(1). That hasn't been
true for some very long time, so the need to always store the return status
of dialog(1) and then call some function to clean-up is long-deprecated. The
function that used to do the clean-up was f_dialog_menutag().

We really don't need f_dialog_menutag() for its originally designed purpose,
as all dialog invocations (even when in a sub-shell) do not use temporary
files anymore.

However, we do need to keep f_dialog_menutag() around because it still fills
the need of being able to abstract the procedure for fetching stored data
provided by functions that display the aforementioned widgets.

In re-designing f_dialog_menutag(), four important changes are made:

1. Rename f_dialog_menutag() to f_dialog_menutag_fetch()
2. Introduce the new first-argument of $var_to_set to reduce number of forks
3. Create a corresponding f_dialog_menutag_store() to abstract the storage
4. Offload the sanitization to a new function, f_dialog_data_sanitize()

NOTE: That last one is important. Not all functions need to store their data
for later fetching, meanwhile every invocation of dialog should be sanitized
(as we learned early-on in the i18n-effort -- underlying libraries will spit
warnings to stderr for bad values of $LANG and since dialog outputs its
responses to stderr, we need to sanitize every response of these warnings).

These changes greatly improve readbaility and also improve performance by
reducing unnecessary forking.
This commit is contained in:
Devin Teske 2013-06-01 23:58:44 +00:00
parent f416c89cb3
commit fd962ac699
43 changed files with 338 additions and 373 deletions

View File

@ -187,8 +187,8 @@ dialog_menu_main()
\"\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--clear \
--title \"\$title\" \
--backtitle \"\$btitle\" \
@ -205,10 +205,11 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
# Only update default-item on success
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu"
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -298,7 +299,7 @@ fi
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
if [ $retval -eq 2 ]; then

View File

@ -70,8 +70,8 @@ dialog_menu_main()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -84,8 +84,9 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DEFAULTITEM_$$ "$dialog_menu"
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -115,11 +116,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"X $msg_exit") break ;;

View File

@ -95,8 +95,8 @@ dialog_menu_main()
swiss-8x8) defaultitem="e $msg_swiss";;
esac
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -109,7 +109,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -139,11 +139,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"1 $msg_none") # Use hardware default font

View File

@ -193,8 +193,8 @@ dialog_menu_main()
) && defaultitem=" $defaultitem"
fi
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -207,7 +207,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -237,11 +237,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
#
# Reverse the users choice into the variable name

View File

@ -75,8 +75,8 @@ dialog_menu_main()
[Nn][Oo]|'') defaultitem="$msg_default";;
esac
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -89,7 +89,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -119,11 +119,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"$msg_slow") # Slow keyboard repeat rate

View File

@ -94,8 +94,8 @@ dialog_menu_main()
[Nn][Oo]|'') defaultitem="d $msg_none" ;;
esac
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -108,7 +108,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -138,11 +138,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"1 $msg_blank") # Simply blank the screen

View File

@ -79,8 +79,8 @@ dialog_menu_main()
koi8-u2cp866u) defaultitem="6 $msg_koi8_u_to_ibm866u" ;;
esac
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -93,7 +93,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -123,11 +123,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"1 $msg_none") # No screenmap, don't touch font

View File

@ -83,8 +83,8 @@ dialog_menu_main()
\"\$hline\" \
$TTY_MENU_LIST
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -96,7 +96,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -182,11 +182,9 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
[ $retval -eq 0 ] || f_die
[ "$mtag" = "1 $msg_none" ] && break
consterm=$( eval f_dialog_menutag2item \"\$mtag\" $TTY_MENU_LIST )

View File

@ -69,8 +69,8 @@ dialog_menu_main()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -83,8 +83,9 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DEFAULTITEM_$$ "$dialog_menu"
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -114,11 +115,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"X $msg_exit") break ;;

View File

@ -79,8 +79,8 @@ dialog_menu_main()
/dev/mse0) defaultitem="6 $msg_busmouse" ;;
esac
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -93,7 +93,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -123,11 +123,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"1 $msg_ps2") # PS/2 style mouse (/dev/psm0)

View File

@ -87,8 +87,8 @@ dialog_menu_main()
thinkingmouse) defaultitem="A $msg_thinkingmouse" ;;
esac
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -101,7 +101,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -131,11 +131,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"1 $msg_auto") # Bus mouse, PS/2 style mouse or PnP serial mouse

View File

@ -73,13 +73,10 @@ f_mustberoot_init
#
defaultitem=""
while :; do
f_dialog_menu_netdev "$defaultitem"
retval=$?
interface=$( f_dialog_menutag )
f_dialog_menu_netdev "$defaultitem" || break
f_dialog_menutag_fetch interface
defaultitem="$interface"
[ $retval -eq 0 ] || break
#
# dialog_menu_netdev adds an asterisk (*) to the right of the
# device name if the interface is active. Remove the asterisk

View File

@ -67,8 +67,8 @@ dialog_menu_main()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -81,8 +81,9 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DEFAULTITEM_$$ "$dialog_menu"
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -112,11 +113,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
X) # Exit

View File

@ -151,8 +151,8 @@ f_dialog_menu_netdev()
\"\$prompt\" \
\"\$hline\" \
$interfaces
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -165,7 +165,7 @@ f_dialog_menu_netdev()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -224,8 +224,8 @@ f_dialog_menu_netdev_edit()
\"\$prompt\" \
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local tag
tag=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -240,10 +240,8 @@ f_dialog_menu_netdev_edit()
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
local tag="$( f_dialog_menutag )"
f_dialog_data_sanitize tag
if [ $retval -eq 2 ]; then
# The Help button was pressed

View File

@ -205,8 +205,8 @@ f_dialog_menu_media_options()
local hline="$hline_arrows_tab_enter"
local dialog_menu
dialog_menu=$( eval $DIALOG \
local tag
tag=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -216,11 +216,10 @@ f_dialog_menu_media_options()
$supported_media \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize tag
if [ $retval -eq $SUCCESS ]; then
local tag="$( f_dialog_menutag )"
options=$( eval f_dialog_menutag2item \"\$tag\" \
$supported_media )
[ "$options" = "$opt_none" ] && options=

View File

@ -435,8 +435,8 @@ f_dialog_menu_nameservers()
\"\$prompt\" \
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local tag
tag=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -448,10 +448,8 @@ f_dialog_menu_nameservers()
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
local tag="$( f_dialog_menutag )" ns=""
f_dialog_data_sanitize tag
# Return if "Cancel" was chosen (-1) or ESC was pressed (255)
if [ $retval -ne $SUCCESS ]; then
@ -467,6 +465,7 @@ f_dialog_menu_nameservers()
f_dialog_input_nameserver
;;
*)
local n ns
n=$( eval f_dialog_menutag2index \"\$tag\" $menu_list )
ns=$( eval f_dialog_menutag2item \"\$tag\" $menu_list )
f_dialog_input_nameserver $(( $n - 2 )) "$ns"

View File

@ -81,8 +81,8 @@ dialog_menu_main()
defaultitem="$msg_disabled"
esac
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -98,7 +98,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -130,7 +130,7 @@ f_mustberoot_init
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
if [ $retval -eq 2 ]; then
# The Help button was pressed

View File

@ -105,8 +105,8 @@ dialog_menu_main()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -119,10 +119,11 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
# Only update default-item on success
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu"
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -153,11 +154,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"X <<< $msg_exit") break ;;

View File

@ -619,6 +619,7 @@ f_device_menu()
case $- in *e*) errexit=1; esac
set +e
local mtag
while :; do
mtag=$( eval $DIALOG \
--title \"\$title\" \
@ -648,8 +649,7 @@ f_device_menu()
if [ $retval -eq 0 ]; then
# Clean up the output of [X]dialog(1) and return it
setvar DIALOG_MENU_$$ "$mtag"
mtag=$( f_dialog_menutag )
f_dialog_data_sanitize mtag
echo "$mtag" >&2
fi

View File

@ -107,6 +107,45 @@ DIALOG_TIMEBOX_HEIGHT=6
############################################################ GENERIC FUNCTIONS
# f_dialog_data_sanitize $var_to_edit ...
#
# When using dialog(1) or Xdialog(1) sometimes unintended warnings or errors
# are generated from underlying libraries. For example, if $LANG is set to an
# invalid or unknown locale, the warnings from the Xdialog(1) libraries will
# clutter the output. This function helps by providing a centralied function
# that removes spurious warnings from the dialog(1) (or Xdialog(1)) response.
#
# Simply pass the name of one or more variables that need to be sanitized.
# After execution, the variables will hold their newly-sanitized data.
#
f_dialog_data_sanitize()
{
if [ "$#" -eq 0 ]; then
f_dprintf "%s: called with zero arguments" \
f_dialog_response_sanitize
return $FAILURE
fi
local __var_to_edit
for __var_to_edit in $*; do
# Skip warnings and trim leading/trailing whitespace
setvar $__var_to_edit "$( f_getvar $__var_to_edit | awk '
BEGIN { data = 0 }
{
if ( ! data )
{
if ( $0 ~ /^$/ ) next
if ( $0 ~ /^Gdk-WARNING \*\*:/ ) next
data = 1
}
print
}
' )"
done
}
############################################################ TITLE FUNCTIONS
# f_dialog_title [$new_title]
#
# Set the title of future dialog(1) ($DIALOG_TITLE) or backtitle of Xdialog(1)
@ -1622,29 +1661,41 @@ f_dialog_input()
############################################################ MENU FUNCTIONS
# f_dialog_menutag
# f_dialog_menutag_store [-s] $text
#
# Store some text from a dialog(1) menu to be retrieved later by
# f_dialog_menutag_fetch(). If the first argument is `-s', the text is
# sanitized before being stored.
#
f_dialog_menutag_store()
{
local sanitize=
[ "$1" = "-s" ] && sanitize=1 && shift 1 # -s
local text="$1"
# Sanitize the menutag before storing it if desired
[ "$sanitize" ] && f_dialog_data_sanitize text
setvar DIALOG_MENU_$$ "$text"
}
# f_dialog_menutag_fetch [$var_to_set]
#
# Obtain the menutag chosen by the user from the most recently displayed
# dialog(1) menu and clean up any temporary files/variables.
# dialog(1) menu (previously stored with f_dialog_menutag_store() above). If
# $var_to_set is NULL or missing, output is printed to stdout (which is less
# recommended due to performance degradation; in a loop for example).
#
f_dialog_menutag()
f_dialog_menutag_fetch()
{
# Skip warnings
eval echo \"\$DIALOG_MENU_$$\" | awk '
BEGIN { found = 0 }
{
if ( found ) # ... just spew
{
print
next
}
if ( $0 ~ /^$/ ) next
if ( $0 ~ /^Gdk-WARNING \*\*:/ ) next
found = 1
print
}
'
local __var_to_set="$1" __cp
debug= f_getvar DIALOG_MENU_$$ "${__var_to_set:-__cp}" # get the data
setvar DIALOG_MENU_$$ "" # scrub memory in case data was sensitive
# Return the data on standard-out if desired
[ "$__var_to_set" ] || echo "$__cp"
return $SUCCESS
}

View File

@ -94,10 +94,9 @@ f_media_get_type()
\"\$hline\" \
$menu_list
local dialog_menu
local mtag
while :; do
dialog_menu=$( eval $DIALOG \
mtag=$( eval $DIALOG \
--title \"\$title\" \
--backtitle \"\$btitle\" \
--hline \"\$hline\" \
@ -112,10 +111,7 @@ f_media_get_type()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
local mtag
mtag=$( f_dialog_menutag )
f_dialog_data_sanitize mtag
f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
if [ $retval -eq 2 ]; then

View File

@ -237,8 +237,8 @@ f_dialog_menu_media_ftp()
\"\$hline\" \
$menu_list
local dialog_menu retval mtag value
dialog_menu=$( eval $DIALOG \
local mtag
mtag=$( eval $DIALOG \
--title \"\$title\" \
--backtitle \"\$btitle\" \
--hline \"\$hline\" \
@ -248,16 +248,13 @@ f_dialog_menu_media_ftp()
$height $width $rows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || return $FAILURE
) || return $FAILURE
f_dialog_data_sanitize mtag
case "$mtag" in
URL) setvar $VAR_FTP_PATH "other" ;;
*)
local value
value=$( eval f_dialog_menutag2item \"\$mtag\" $menu_list )
setvar $VAR_FTP_PATH "ftp://$value"
esac

View File

@ -208,9 +208,8 @@ f_media_options_menu()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local mtag
mtag=$( eval $DIALOG \
--title \"\$title\" \
--backtitle \"\$btitle\" \
--hline \"\$hline\" \
@ -227,11 +226,8 @@ f_media_options_menu()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
defaultitem="$dialog_menu"
local mtag
mtag=$( f_dialog_menutag )
f_dialog_data_sanitize mtag
defaultitem="$mtag"
f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
if [ $retval -eq 2 ]; then

View File

@ -1399,8 +1399,7 @@ f_device_dialog_tcp()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$cp"
cp=$( f_dialog_menutag )
f_dialog_data_sanitize cp
f_dprintf "retval=%u mtag=[%s]" $retval "$cp"
if [ $retval -eq 2 ]; then

View File

@ -105,8 +105,8 @@ f_become_root_via_sudo()
\"\$hline\" \
$menu_list
local dialog_menu mtag retval
dialog_menu=$( eval $DIALOG \
local mtag
mtag=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -116,12 +116,8 @@ f_become_root_via_sudo()
$height $width $rows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
) || f_die
f_dialog_data_sanitize mtag
case "$mtag" in
X) # Cancel/Exit

View File

@ -272,8 +272,8 @@ f_package_calculate_rundeps()
# Dislay the menu of package categories, complete with package counts for each
# category, accents, and other miscellany. If $defaultitem is non-NULL and
# matches one of the existing menu-items, it will be pre-highlighted in the
# menu dialog (HINT: Use f_dialog_menutag() to populate a local variable that
# is passed as $defaultitem to highlight the user's last selection by default).
# menu dialog (HINT: Use f_dialog_menutag_fetch() to populate a local variable
# that is passed as $defaultitem to highlight the user's last selection).
#
f_package_menu_categories()
{
@ -297,14 +297,15 @@ f_package_menu_categories()
$category_list
" # End-Quote
local height width rows dialog_menu
local height width rows
eval f_dialog_menu_with_help_size height width rows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
\"\$prompt\" \
\"\$hline\" \
$menu_list
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -318,7 +319,7 @@ f_package_menu_categories()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -360,7 +361,7 @@ f_package_index_get_page()
#
# On success, if the user doesn't press ESC or choose Cancel, the environment
# variable $DIALOG_MENUITEM_$$ will hold the item associated with the chosen
# tag (accessible through f_dialog_menutag()).
# tag (accessible through f_dialog_menutag_fetch()).
#
f_package_menu_select()
{
@ -464,8 +465,9 @@ f_package_menu_select()
f_dialog_infobox_size iheight iwidth \
"$DIALOG_TITLE" "$DIALOG_BACKTITLE" \
"$msg_processing_selection"
local dialog_menu item
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -484,11 +486,13 @@ f_package_menu_select()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
if [ $retval -eq $SUCCESS ]; then
local item
item=$( eval f_dialog_menutag2item${SHOW_DESC:+_with_help} \
\"\$dialog_menu\" $menu_list )
\"\$menu_choice\" $menu_list )
setvar DIALOG_MENUITEM_$$ "$item"
fi
@ -501,11 +505,11 @@ f_package_menu_select()
# with regard to "deselecting" an already installed package. Choices include
# uninstall, re-install, or cancel (leave $package marked as installed).
# Returns success if the user does not press ESC or choose Cnacel. Use the
# f_dialog_menutag() function upon success to retrieve the user's choice.
# f_dialog_menutag_fetch() function upon success to retrieve the user's choice.
#
f_package_menu_deselect()
{
local package="$1" prompt menu_list dialog_menu
local package="$1" prompt menu_list
prompt=$( printf "$msg_what_would_you_like_to_do_with" "$package" )
local hline="$hline_alnum_arrows_punc_tab_enter"
menu_list="
@ -521,8 +525,8 @@ f_package_menu_deselect()
\"\$prompt\" \
\"\$hline\" \
$menu_list
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -534,7 +538,7 @@ f_package_menu_deselect()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -547,7 +551,7 @@ f_package_menu_deselect()
#
f_package_review()
{
local prompt dialog_menu package varpkg mark menu_list=
local prompt package varpkg mark menu_list=
prompt=$( printf "$msg_reviewing_selected_packages" \
"$_All_nselected" )
local hline="$hline_alnum_arrows_punc_tab_enter"
@ -576,7 +580,8 @@ f_package_review()
\"\$hline\" \
$menu_list
dialog_menu=$( eval $DIALOG \
# Show the review menu (ignore menu choice)
eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -585,10 +590,8 @@ f_package_review()
--menu \"\$prompt\" \
$height $width $rows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
2> /dev/null
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
#
# XXX
@ -626,7 +629,7 @@ f_package_config()
f_package_menu_categories \
CATEGORY_MENU_LIST "$category_defaultitem"
retval=$?
category=$( f_dialog_menutag )
f_dialog_menutag_fetch category
f_dprintf "retval=%u mtag=[%s]" $retval "$category"
category_defaultitem="$category"
@ -648,7 +651,7 @@ f_package_config()
f_str2varname "$category" varcat
local page package varpkg mark
local page package varpkg mark menu_choice
while :; do
# Display the list of packages for selected category
page=1 defaultitem=""
@ -657,8 +660,8 @@ f_package_config()
f_package_menu_select \
"$category" "${page:=1}" "$defaultitem"
retval=$?
dialog_menu=$( f_dialog_menutag )
f_dprintf "retval=%u mtag=[%s]" $retval "$dialog_menu"
f_dialog_menutag_fetch menu_choice
f_dprintf "retval=%u mtag=[%s]" $retval "$menu_choice"
# NOTE: When --and-widget is used only ESC will cause
# dialog(1) to return without going to the next widget.
@ -666,24 +669,24 @@ f_package_config()
# the Cancel button because stdout will be NULL.
# Alternatively, Xdialog(1) will terminate with 1
# if/when Cancel is chosen on any widget.
if [ $retval -eq 255 -o ! "$dialog_menu" ]; then
if [ $retval -eq 255 -o ! "$menu_choice" ]; then
# User pressed ESC or chose Cancel
break
elif [ $retval -eq 1 ]; then
# Using X11, Xdialog(1) returned 1 for Cancel
f_show_msg "%s" "$dialog_menu"
f_show_msg "%s" "$menu_choice"
break
elif [ $retval -ne $SUCCESS ]; then
# X11-related error occurred using Xdialog(1)
f_show_msg "%s" "$dialog_menu"
f_show_msg "%s" "$menu_choice"
break
fi
defaultitem="$dialog_menu"
defaultitem="$menu_choice"
# NOTE: f_package_menu_select() does not show the
# `Previous Page' or `Next Page' items unless needed
case "$dialog_menu" in
case "$menu_choice" in
"> $msg_previous_page"|"> $msg_previous_page*")
page=$(( $page - 1 ))
setvar _defaultpage_$varcat $page
@ -722,7 +725,7 @@ f_package_config()
esac
# Treat any other selection as a package
package="${dialog_menu# }" # Trim leading space
package="${menu_choice# }" # Trim leading space
f_str2varname $package varpkg
f_getvar DIALOG_MENUITEM_$$ mark
mark="${mark#?}"
@ -738,8 +741,8 @@ f_package_config()
;;
"X"|"R"|"U")
f_package_menu_deselect $package || continue
dialog_menu=$( f_dialog_menutag )
case "$dialog_menu" in
f_dialog_menutag_fetch menu_choice
case "$menu_choice" in
"X $msg_installed")
f_package_deselect "$package"
mark="X"

View File

@ -273,8 +273,8 @@ dialog_menu_main()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -287,8 +287,9 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DEFAULTITEM_$$ "$dialog_menu"
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -339,11 +340,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"X <<< $msg_exit") break ;;

View File

@ -74,8 +74,8 @@ dialog_menu_main()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -87,7 +87,7 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -117,21 +117,15 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
1) # Add From List
# Loop for easy return
while :; do
f_dialog_input_rclist
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || break
f_dialog_input_rclist || break
f_dialog_menutag_fetch mtag
case "$mtag" in
"X $msg_exit" ) break ;;

View File

@ -170,8 +170,8 @@ dialog_menu_main()
\"\$hline\" \
$RCCONF_MENU_LIST
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -187,10 +187,11 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
# Only update default-item on success
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu"
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -220,7 +221,7 @@ f_mustberoot_init
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
if [ "$USE_XDIALOG" ]; then
case "$mtag" in

View File

@ -205,8 +205,8 @@ dialog_menu_main()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -223,10 +223,11 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
# Only update default-item on success
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu"
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -331,7 +332,7 @@ dialog_create_main
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
if [ "$USE_XDIALOG" ]; then
case "$mtag" in "> $msg_view_details")

View File

@ -134,8 +134,8 @@ dialog_menu_main()
\"\$hline\" \
$RCVAR_MENU_LIST
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -150,8 +150,9 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DEFAULTITEM_$$ "$dialog_menu"
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -178,11 +179,8 @@ f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
"X $msg_exit") break ;;

View File

@ -311,8 +311,8 @@ f_dialog_input_view_details()
f_dialog_title "$msg_choose_view_details"
local dialog_menu
dialog_menu=$( eval $DIALOG \
local mtag
mtag=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -324,10 +324,8 @@ f_dialog_input_view_details()
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
local mtag="$( f_dialog_menutag )"
f_dialog_data_sanitize mtag
f_dialog_title_restore
@ -364,8 +362,8 @@ f_dialog_input_view_details()
#
# Presents a menu of rc.conf(5) defaults (with, or without descriptions). This
# function should be treated like a call to dialog(1) (the exit status should
# be captured and f_dialog_menutag() should be used to clean-up and get the
# user's response).
# be captured and f_dialog_menutag_fetch() should be used to get the user's
# response).
#
f_dialog_input_rclist()
{
@ -424,8 +422,8 @@ f_dialog_input_rclist()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -437,7 +435,7 @@ f_dialog_input_rclist()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}

View File

@ -67,8 +67,8 @@ dialog_menu_main()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -81,8 +81,9 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DEFAULTITEM_$$ "$dialog_menu"
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -112,11 +113,8 @@ f_mustberoot_init
# Launch application main menu
#
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
[ $retval -eq 0 ] || f_die
dialog_menu_main || f_die
f_dialog_menutag_fetch mtag
case "$mtag" in
X) # Exit

View File

@ -92,8 +92,8 @@ dialog_menu_main()
\"\" \
$continent_menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$title\" \
--backtitle \"\$btitle\" \
--ok-label \"\$msg_ok\" \
@ -105,8 +105,9 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DEFAULTITEM_$$ "$dialog_menu"
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -296,7 +297,7 @@ while :; do
if [ "$NEED_CONTINENT" ]; then
dialog_menu_main # prompt the user to select a continent/ocean
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
if [ $retval -ne 0 ]; then
[ "$TZ_OR_FAIL" ] && f_die
@ -364,7 +365,7 @@ while :; do
#
# Launch the country selection menu
#
dialog_menu=$( eval $DIALOG \
tag=$( eval $DIALOG \
--title \"\$title\" \
--backtitle \"\$btitle\" \
--ok-label \"\$msg_ok\" \
@ -376,8 +377,7 @@ while :; do
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
tag=$( f_dialog_menutag )
f_dialog_data_sanitize tag
defaultctry="$tag"
if [ $retval -ne 0 ]; then
@ -424,7 +424,7 @@ while :; do
# Launch the zone selection menu
# NOTE: This is as deep as we go
#
dialog_menu=$( eval $DIALOG \
n=$( eval $DIALOG \
--title \"\$title\" \
--backtitle \"\$btitle\" \
--ok-label \"\$msg_ok\" \
@ -436,8 +436,7 @@ while :; do
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
n=$( f_dialog_menutag )
f_dialog_data_sanitize n
defaultzone="$n"
if [ $retval -ne 0 ]; then

View File

@ -71,7 +71,7 @@ defaultitem=""
while :; do
f_dialog_menu_group_list "$defaultitem"
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
defaultitem="$mtag"

View File

@ -71,7 +71,7 @@ defaultitem=""
while :; do
f_dialog_menu_group_list "$defaultitem"
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
defaultitem="$mtag"

View File

@ -228,7 +228,7 @@ while :; do
\"\$hline\" \
$menu_items
dialog_menu=$( eval $DIALOG \
mtag=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -240,11 +240,9 @@ while :; do
$menu_items \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DEFAULTITEM_$$ "$dialog_menu"
setvar DIALOG_MENU_$$ "$dialog_menu"
mtag=$( f_dialog_menutag )
f_dialog_data_sanitize mtag
setvar DEFAULTITEM_$$ "$mtag"
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Exit if user has either pressed ESC or chosen Cancel/No
@ -263,7 +261,7 @@ while :; do
Edit/View|Delete)
f_dialog_menu_group_list "$group_name"
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Loop if user has either pressed ESC or chosen Cancel/No

View File

@ -88,8 +88,8 @@ f_dialog_menu_group_list()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -102,7 +102,7 @@ f_dialog_menu_group_list()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -310,7 +310,7 @@ f_dialog_input_group_members()
'2' '$msg_enter_group_members_manually'
" # END-QUOTE
local dialog_menu defaultitem=
local menu_choice defaultitem=
local mheight mwidth mrows
eval f_dialog_menu_size mheight mwidth mrows \
\"\$DIALOG_TITLE\" \
@ -320,7 +320,7 @@ f_dialog_input_group_members()
$menu_list
while :; do
dialog_menu=$( eval $DIALOG \
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -333,9 +333,8 @@ f_dialog_input_group_members()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
defaultitem="$dialog_menu"
menu_choice=$( f_dialog_menutag )
f_dialog_data_sanitize menu_choice
defaultitem="$menu_choice"
f_dprintf "retval=%u menu_choice=[%s]" $retval "$menu_choice"
# Return if user has either pressed ESC or chosen Cancel/No
@ -364,8 +363,7 @@ f_dialog_input_group_members()
\"\" \
\"\$hline\" \
$checklist_users
local dialog_inputbox
dialog_inputbox=$( eval $DIALOG \
_group_members=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--separate-output \
@ -376,15 +374,18 @@ f_dialog_input_group_members()
$cheight $cwidth $crows \
$checklist_users \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
_group_members=$( f_dialog_inputstr | tr '\n' ' ' |
sed -e 's/[[:space:]]\{1,\}/,/g;s/^,//;s/,$//' )
) || continue
# Return to previous menu if user either
# pressed ESC or chose Cancel/No
f_dialog_data_sanitize _group_members
# Return to previous menu if user has either
# pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || continue
# Convert the newline separated list into a comma-
# separated one so that if the user switches over to
# manual editing, list reflects checklist selections
_group_members=$( echo "$_group_members" |
tr '\n' ' ' |
sed -e 's/[[:space:]]\{1,\}/,/g;s/^,//;s/,$//'
)
_input="$_group_members"
;;

View File

@ -113,8 +113,8 @@ f_dialog_menu_user_list()
\"\$hline\" \
$menu_list
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -127,7 +127,7 @@ f_dialog_menu_user_list()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_menutag_store -s "$menu_choice"
return $retval
}
@ -168,8 +168,7 @@ f_dialog_input_member_groups()
\"\" \
\"\$hline\" \
$checklist_groups
local dialog_inputbox
dialog_inputbox=$( eval $DIALOG \
_member_groups=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--separate-output \
@ -180,14 +179,9 @@ f_dialog_input_member_groups()
$height $width $rows \
$checklist_groups \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
_member_groups=$( f_dialog_inputstr )
# Return if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || return $retval
) || return $?
# Return if user either pressed ESC or chose Cancel/No
f_dialog_data_sanitize _member_groups
#
# Validate each of the groups the user has entered
@ -503,9 +497,9 @@ f_dialog_input_change()
#
# Loop until the user provides taint-free/cancellation-free input
#
local date_type
while :; do
local dialog_menu
dialog_menu=$( eval $DIALOG \
date_type=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -517,8 +511,7 @@ f_dialog_input_change()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
date_type=$( f_dialog_menutag )
f_dialog_data_sanitize date_type
f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
# Return if user has either pressed ESC or chosen Cancel/No
@ -536,8 +529,7 @@ f_dialog_input_change()
{ f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
_input_date=$( date -j -f "%s" -- "$secs" \
"+%d %m %Y" 2> /dev/null )
local dialog_inputbox
dialog_inputbox=$( eval $DIALOG \
ret_date=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -549,8 +541,7 @@ f_dialog_input_change()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
ret_date=$( f_dialog_inputstr )
f_dialog_data_sanitize ret_date
f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
# Return to menu if either ESC or Cancel/No
@ -559,8 +550,7 @@ f_dialog_input_change()
_input_time=
[ "$secs" ] && _input_time=$( date -j \
-f %s -- "$_input" "+%H %M %S" 2> /dev/null )
local dialog_inputbox
dialog_inputbox=$( eval $DIALOG \
ret_time=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -572,8 +562,7 @@ f_dialog_input_change()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
ret_time=$( f_dialog_inputstr )
f_dialog_data_sanitize ret_time
f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
# Return to menu if either ESC or Cancel/No
@ -694,9 +683,9 @@ f_dialog_input_expire()
#
# Loop until the user provides taint-free/cancellation-free input
#
local date_type
while :; do
local dialog_menu
dialog_menu=$( eval $DIALOG \
date_type=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -708,8 +697,7 @@ f_dialog_input_expire()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
date_type=$( f_dialog_menutag )
f_dialog_data_sanitize date_type
f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
# Return if user has either pressed ESC or chosen Cancel/No
@ -727,8 +715,7 @@ f_dialog_input_expire()
{ f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
_input_date=$( date -j -f "%s" -- "$secs" \
"+%d %m %Y" 2> /dev/null )
local dialog_inputbox
dialog_inputbox=$( eval $DIALOG \
ret_date=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -740,8 +727,7 @@ f_dialog_input_expire()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
ret_date=$( f_dialog_inputstr )
f_dialog_data_sanitize ret_date
f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
# Return to menu if either ESC or Cancel/No
@ -750,7 +736,7 @@ f_dialog_input_expire()
_input_time=
[ "$secs" ] && _input_time=$( date -j \
-f %s -- "$_input" "+%H %M %S" 2> /dev/null )
dialog_inputbox=$( eval $DIALOG \
ret_time=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -762,8 +748,7 @@ f_dialog_input_expire()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
ret_time=$( f_dialog_inputstr )
f_dialog_data_sanitize ret_time
f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
# Return to menu if either ESC or Cancel/No
@ -998,7 +983,7 @@ f_dialog_input_dotfiles_create()
#
f_dialog_input_shell()
{
local retval shells shell_list _input="$1"
local shells shell_list _input="$1"
local hline="$hline_arrows_space_tab_enter"
local prompt="$msg_select_login_shell"
@ -1021,8 +1006,7 @@ f_dialog_input_shell()
\"\$hline\" \
$shell_list
local dialog_inputbox
dialog_inputbox=$( eval $DIALOG \
_input=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -1032,14 +1016,9 @@ f_dialog_input_shell()
$height $width $rows \
$shell_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
_input=$( f_dialog_inputstr )
# Return if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || return $retval
) || return $?
# Return if user either pressed ESC or chose Cancel/No
f_dialog_data_sanitize _input
pw_shell="$_input"
save_flag=1

View File

@ -71,7 +71,7 @@ defaultitem=""
while :; do
f_dialog_menu_user_list "$defaultitem"
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
defaultitem="$mtag"

View File

@ -71,7 +71,7 @@ defaultitem=""
while :; do
f_dialog_menu_user_list "$defaultitem"
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
defaultitem="$mtag"

View File

@ -391,7 +391,7 @@ while :; do
\"\$hline\" \
$menu_items
dialog_menu=$( eval $DIALOG \
mtag=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -403,11 +403,9 @@ while :; do
$menu_items \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
setvar DEFAULTITEM_$$ "$dialog_menu"
setvar DIALOG_MENU_$$ "$dialog_menu"
mtag=$( f_dialog_menutag )
f_dialog_data_sanitize mtag
setvar DEFAULTITEM_$$ "$mtag"
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Exit if user has either pressed ESC or chosen Cancel/No
@ -426,7 +424,7 @@ while :; do
Edit/View|Delete)
f_dialog_menu_user_list "$pw_name"
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Loop if user has either pressed ESC or chosen Cancel/No

View File

@ -76,8 +76,8 @@ dialog_menu_main()
# When using Xdialog(1) we need to bump the width for the buttons
[ "$USE_XDIALOG" ] && width=40
local dialog_menu
dialog_menu=$( eval $DIALOG \
local menu_choice
menu_choice=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
--hline \"\$hline\" \
@ -93,10 +93,11 @@ dialog_menu_main()
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
# Only update default-item on success
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu"
[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
return $retval
}
@ -129,7 +130,7 @@ f_mustberoot_init
while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
f_dialog_menutag_fetch mtag
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
if [ $retval -eq 2 ]; then