summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorHenrik Hallberg <henrik@k2h.se>2012-06-21 23:13:06 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2012-06-22 12:27:16 +0200
commit82d594456df94421b458c1b340cd1ac4d34baa86 (patch)
tree7e299aff5e1eda976c35fd1dfa9c1ac79b86e2fb /scripts
parent5ac724b8d139b7e38c3a16c8752bad55076ea670 (diff)
downloadnetctl-82d594456df94421b458c1b340cd1ac4d34baa86.tar.gz
netctl-82d594456df94421b458c1b340cd1ac4d34baa86.tar.xz
Do without temporary file for netcfg-menu dialog
Signed-off-by: Henrik Hallberg <henrik@k2h.se>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/netcfg-menu18
1 files changed, 6 insertions, 12 deletions
diff --git a/scripts/netcfg-menu b/scripts/netcfg-menu
index 1ca5e32..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
- read 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: