On Thu, Jun 21, 2012 at 10:12:23PM +0200, Henrik Hallberg wrote:
Signed-off-by: Henrik Hallberg <henrik@k2h.se> --- scripts/netcfg-menu | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/scripts/netcfg-menu b/scripts/netcfg-menu index d0db762..0fc0736 100755 --- a/scripts/netcfg-menu +++ b/scripts/netcfg-menu @@ -3,7 +3,7 @@ . /usr/lib/network/network
if ! type dialog &> /dev/null; then - echo "Please install 'dialog' to use netcfg-menu" + echo 'Please install '\'dialog\'' to use netcfg-menu'
This is unrelated, and a no-op change.
exit 1 fi
@@ -17,7 +17,7 @@ i=0 # JP: change for prof to while read prof to avoid assumption that profile names are always single tokens (no spaces etc.) while read prof; do # if there is a profile called "main", Use as default - [[ "$prof" = "main" ]] && DEFAULT="main" + [[ "$prof" = main ]] && DEFAULT=main
This is unrelated, and a no-op change.
profiles[i++]="$prof" profiles[i++]=$(. "$PROFILE_DIR/$prof"; echo "$DESCRIPTION") done < <(list_profiles | sort) # JP: re-use list_profiles instead of duplicating it; avoid subshell we'd get by piping it to the while read... @@ -29,29 +29,23 @@ fi [[ -n "$NETWORKS_MENU_DEFAULT" ]] && DEFAULT="$NETWORKS_MENU_DEFAULT" # if no default yet, use the first entry [[ -z "$DEFAULT" ]] && DEFAULT="${profiles[0]}" -ANSWER=$(mktemp --tmpdir menu.XXXXXXXX) || exit 1
# Set timeout if [[ -z "$1" ]]; then - TIMEOUT="0" + TIMEOUT=0
This is unrelated, and a no-op change.
else TIMEOUT="$1" fi
# Display Dialog -dialog --timeout "$TIMEOUT" --default-item "$DEFAULT" \ - --menu "Select the network profile you wish to use" \ - 13 50 6 "${profiles[@]}" 2> "$ANSWER" - +PROFILE=$(dialog --timeout "$TIMEOUT" --default-item "$DEFAULT" --stdout \ + --menu 'Select the network profile you wish to use' \ + 13 50 6 "${profiles[@]}") ret=$? - case $ret in 1) ;; # Cancel - do nothing - 255) # timeout - use default - PROFILE=$DEFAULT;;& - 0) # User selection - PROFILE=$(< "$ANSWER");;& - 255|0) + 255|0) # Timeout (use default) or user selection + [[ -z "$PROFILE" ]] && PROFILE="$DEFAULT" profile_up "$PROFILE" ret=$? (( ret == 0 )) && echo "$PROFILE" > "$STATE_DIR/menu" @@ -60,7 +54,7 @@ case $ret in exit_err "Abnormal ret code from dialog: $ret" ;; esac -rm -f "$ANSWER" # JP: add -f + exit $ret # JP: exit with caught $?
# vim: ft=sh ts=4 et sw=4: -- 1.7.11