From 29b8a7c378cd275c4c1f8d8c995b65cdf19657af Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Tue, 11 Aug 2009 08:05:02 -0400 Subject: Improve listing/iterating over profiles Signed-off-by: Jim Pryor --- src/netcfg-menu | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/netcfg-menu') 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" -- cgit v1.2.3-24-g4f1b