mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add -space option to foamCleanPath
- this allows more direct use by c-shell
This commit is contained in:
@ -41,7 +41,11 @@
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
usage() {
|
usage() {
|
||||||
cat <<USAGE 1>&2
|
cat <<USAGE 1>&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
|
Prints its argument (which should be a ':' separated list) cleansed from
|
||||||
- duplicate elements
|
- duplicate elements
|
||||||
@ -53,7 +57,7 @@ USAGE
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unset strip
|
unset space strip
|
||||||
# parse options
|
# parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
@ -61,6 +65,10 @@ do
|
|||||||
-h | -help)
|
-h | -help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
-space)
|
||||||
|
space=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-strip)
|
-strip)
|
||||||
strip=true
|
strip=true
|
||||||
shift
|
shift
|
||||||
@ -74,7 +82,12 @@ done
|
|||||||
|
|
||||||
[ "$#" -ge 1 ] || usage
|
[ "$#" -ge 1 ] || usage
|
||||||
|
|
||||||
dirList="$1"
|
if [ "$space" = true ]
|
||||||
|
then
|
||||||
|
dirList=$(echo "$1" | sed -e 's/ /:/g')
|
||||||
|
else
|
||||||
|
dirList="$1"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
|
|
||||||
##DEBUG echo "input>$dirList<" 1>&2
|
##DEBUG echo "input>$dirList<" 1>&2
|
||||||
@ -123,12 +136,15 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# parse on whitespace
|
# split on whitespace
|
||||||
IFS=' '
|
IFS=' '
|
||||||
set -- $dirList
|
set -- $dirList
|
||||||
|
|
||||||
# join on ':'
|
# join on ':', unless -space option was specified
|
||||||
IFS=':'
|
if [ "$space" != true ]
|
||||||
|
then
|
||||||
|
IFS=':'
|
||||||
|
fi
|
||||||
dirList="$*"
|
dirList="$*"
|
||||||
|
|
||||||
# restore IFS
|
# restore IFS
|
||||||
|
|||||||
Reference in New Issue
Block a user