summaryrefslogtreecommitdiffstats
path: root/src/netcfg-menu
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2009-09-07 12:00:22 +0200
committerJames Rayner <james@archlinux.org>2009-09-07 12:00:22 +0200
commit13406e34b1179d748b98791d1a15387ba053a4fa (patch)
tree4af421b5703462b43929fe56a23808d1680d28da /src/netcfg-menu
parent3ae7e093c27350ced6ffaf99a3bca6bc56c559b8 (diff)
downloadnetctl-13406e34b1179d748b98791d1a15387ba053a4fa.tar.gz
netctl-13406e34b1179d748b98791d1a15387ba053a4fa.tar.xz
Lots of little tweaks that should never hurt. Some of them may help in
corner cases; others probably make no difference. Signed-off-by: Jim Pryor <profjim@jimpryor.net>
Diffstat (limited to 'src/netcfg-menu')
-rw-r--r--src/netcfg-menu14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/netcfg-menu b/src/netcfg-menu
index c5e5324..2736ee1 100644
--- a/src/netcfg-menu
+++ b/src/netcfg-menu
@@ -10,26 +10,26 @@ 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=$prof
+ [ "$prof" = "main" ] && DEFAULT="main"
unset DESCRIPTION # JP: we can''t sandbox the sourced profiles, because we need to expose profiles[]
. "$PROFILE_DIR/$prof"
profiles[$i]="$prof"
- i=$((i+1))
+ let i++
profiles[$i]="$DESCRIPTION" # JP: this will usually have spaces and must be quoted
- i=$((i+1))
+ let i++
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...
-if [ ${#profiles} -eq 0 ]; then
+if [[ ${#profiles} -eq 0 ]]; then
exit_err "No profiles were found in $PROFILE_DIR"
fi
-[ "$NETWORKS_MENU_DEFAULT" ] && DEFAULT="$NETWORKS_MENU_DEFAULT"
+[[ -n "$NETWORKS_MENU_DEFAULT" ]] && DEFAULT="$NETWORKS_MENU_DEFAULT"
# if no default yet, use the first entry
-[ "$DEFAULT" = "" ] && DEFAULT="${profiles[0]}"
+[[ -z "$DEFAULT" ]] && DEFAULT="${profiles[0]}"
ANSWER=$(mktemp --tmpdir menu.XXXXXXXX) || exit 1
# Set timeout
-if [ "$1" = "" ]; then
+if [ -z "$1" ]]; then
TIMEOUT="0"
else
TIMEOUT="$1"