diff options
author | Jim Pryor <profjim@jimpryor.net> | 2009-08-11 14:05:02 +0200 |
---|---|---|
committer | James Rayner <james@archlinux.org> | 2009-08-15 04:28:27 +0200 |
commit | 29b8a7c378cd275c4c1f8d8c995b65cdf19657af (patch) | |
tree | f66472861c788026296baa56b6c406f740a04c01 /src/netcfg-menu | |
parent | efc7183790cec4fc2b3425f17201e0e2fea51c44 (diff) | |
download | netctl-29b8a7c378cd275c4c1f8d8c995b65cdf19657af.tar.gz netctl-29b8a7c378cd275c4c1f8d8c995b65cdf19657af.tar.xz |
Improve listing/iterating over profiles
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
Diffstat (limited to 'src/netcfg-menu')
-rw-r--r-- | src/netcfg-menu | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/netcfg-menu b/src/netcfg-menu index 3c800a1..055cdf0 100644 --- a/src/netcfg-menu +++ b/src/netcfg-menu @@ -5,16 +5,17 @@ # Scan all profiles i=0 -for prof in `find -L $PROFILE_DIR -maxdepth 1 -type f -printf "%f\n"|sort`; do +# 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 - unset DESCRIPTION + 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)) - profiles[$i]=$DESCRIPTION + profiles[$i]="$DESCRIPTION" # JP: this will usually have spaces and must be quoted i=$((i+1)) -done +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 exit_err "No profiles were found in $PROFILE_DIR" |