diff options
author | Jouke Witteveen <j.witteveen@gmail.com> | 2012-03-01 01:33:12 +0100 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2012-03-01 01:35:58 +0100 |
commit | eed3f590c9db7cd9cd4d5fb4722fc7257a278ea6 (patch) | |
tree | d34406a8af61dccbb9655b899da30d04ce61a623 /scripts/netcfg-menu | |
parent | 8d1c5e8ec6b637015e84bbb154ece9065c59f1c5 (diff) | |
download | netctl-eed3f590c9db7cd9cd4d5fb4722fc7257a278ea6.tar.gz netctl-eed3f590c9db7cd9cd4d5fb4722fc7257a278ea6.tar.xz |
Code quality upgrade
This is what you get when Dave Reisner points you at some bash anti-patterns.
Also in this commit:
- updated documentation
- bugfix revision of the IPv6 SLAAC address/route bug
Diffstat (limited to 'scripts/netcfg-menu')
-rwxr-xr-x | scripts/netcfg-menu | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/scripts/netcfg-menu b/scripts/netcfg-menu index ff57005..f7c9019 100755 --- a/scripts/netcfg-menu +++ b/scripts/netcfg-menu @@ -5,7 +5,7 @@ if [[ ! -x /usr/bin/dialog ]]; then echo "Please install 'dialog' to use netcfg-menu" exit 1 -fi +fi check_make_state_dir @@ -18,10 +18,8 @@ i=0 while read prof; do # if there is a profile called "main", Use as default [[ "$prof" = "main" ]] && DEFAULT="main" - profiles[$i]="$prof" - let i++ - profiles[$i]=$(. "$PROFILE_DIR/$prof"; echo "$DESCRIPTION") - let i++ + 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... if [[ ${#profiles} -eq 0 ]]; then @@ -52,12 +50,12 @@ case $ret in 255) # timeout - use default profile_up "$DEFAULT" # JP: use profile_up and catch $? ret=$? - if [[ $ret -eq 0 ]]; then echo "$DEFAULT" > "$STATE_DIR/menu"; fi + (( ret == 0 )) && echo "$DEFAULT" > "$STATE_DIR/menu" ;; 0) # User selection profile_up "$(cat "$ANSWER")" ret=$? - if [[ $ret -eq 0 ]]; then mv "$ANSWER" "$STATE_DIR/menu"; fi + (( ret == 0 )) && mv "$ANSWER" "$STATE_DIR/menu" ;; *) # Shouldnt happen exit_err "Abnormal ret code from dialog: $ret" |