[arch-projects] [netcfg] [PATCH v2] Do without temporary file for netcfg-menu dialog
Jouke Witteveen
j.witteveen at gmail.com
Thu Jun 21 20:10:40 EDT 2012
On Thu, Jun 21, 2012 at 11:13 PM, Henrik Hallberg <henrik at k2h.se> wrote:
> Signed-off-by: Henrik Hallberg <henrik at k2h.se>
> ---
> scripts/netcfg-menu | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/scripts/netcfg-menu b/scripts/netcfg-menu
> index d0db762..86b5d09 100755
> --- a/scripts/netcfg-menu
> +++ b/scripts/netcfg-menu
> @@ -29,7 +29,6 @@ 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
> @@ -39,19 +38,14 @@ else
> 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
>
Is it me, or does this not apply?
- Jouke
More information about the arch-projects
mailing list