From 06910c1cd154242d6aee9b2012310b0f2dfed282 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 5 Mar 2010 14:35:47 +0100 Subject: [PATCH] ENH: add -space option to foamCleanPath - this allows more direct use by c-shell --- bin/foamCleanPath | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/foamCleanPath b/bin/foamCleanPath index fcb5b7068c..0ef171e455 100755 --- a/bin/foamCleanPath +++ b/bin/foamCleanPath @@ -41,7 +41,11 @@ #------------------------------------------------------------------------------ usage() { cat <&2 -Usage: ${0##*/} [-strip] path [wildcard] .. [wildcard] +Usage: ${0##*/} [OPTION] path [wildcard1] .. [wildcardN] +options: + -space treat 'path' as space-delimited (eg, from C-Shell) + -strip remove inaccessible directories + -help print the usage Prints its argument (which should be a ':' separated list) cleansed from - duplicate elements @@ -53,7 +57,7 @@ USAGE } -unset strip +unset space strip # parse options while [ "$#" -gt 0 ] do @@ -61,6 +65,10 @@ do -h | -help) usage ;; + -space) + space=true + shift + ;; -strip) strip=true shift @@ -74,7 +82,12 @@ done [ "$#" -ge 1 ] || usage -dirList="$1" +if [ "$space" = true ] +then + dirList=$(echo "$1" | sed -e 's/ /:/g') +else + dirList="$1" +fi shift ##DEBUG echo "input>$dirList<" 1>&2 @@ -123,12 +136,15 @@ do fi done -# parse on whitespace +# split on whitespace IFS=' ' set -- $dirList -# join on ':' -IFS=':' +# join on ':', unless -space option was specified +if [ "$space" != true ] +then + IFS=':' +fi dirList="$*" # restore IFS