diff --git a/bin/foamCleanPath b/bin/foamCleanPath index dca96f490edd8bef78e9a97c1f23b98ea6e1679b..225aa0e9430f3fbcf874ca965999cc098e2878ad 100755 --- a/bin/foamCleanPath +++ b/bin/foamCleanPath @@ -32,34 +32,47 @@ # Prints its argument (which should be a ':' separated path) # without all # - duplicate elements -# - (if '-strip') non-accessible directories # - elements whose start matches a wildcard +# - inaccessible directories (with the -strip option) # # Note: # - this routine will fail when directories have embedded spaces # - false matches possible if a wildcard contains '.' (sed regex) #------------------------------------------------------------------------------ -if [ "$#" -lt 1 -o "$1" = "-h" -o "$1" = "-help" ] -then - cat <<USAGE 1>&2 -Usage: ${0##*/} [-strip] path [wildcard] .. [wildcard] - - Prints its argument (which should be a ':' separated list) cleansed from - - duplicate elements - - elements whose start matches one of the wildcard(s) - - (if '-strip') non-accessible directories +usage() { + cat <<USAGE 1>&2 +usage: ${0##*/} [-strip] path [wildcard] .. [wildcard] + + Prints its argument (which should be a ':' separated list) cleansed from + - duplicate elements + - elements whose start matches one of the wildcard(s) + - inaccessible directories (with the -strip option) + USAGE - exit 1 -fi + exit 1 +} -strip='' -if [ "$1" = "-strip" ] -then - strip=true - shift -fi +unset strip +# parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help) + usage + ;; + -strip) + strip=true + shift + ;; + *) + break + ;; + esac +done + +[ "$#" -ge 1 ] || usage dirList="$1" shift @@ -79,7 +92,7 @@ do wildcard=$1 shift ##DEBUG echo "remove>$wildcard<" 1>&2 - dirList=`echo "$dirList" | sed -e "s@${wildcard}[^:]*:@@g"` + dirList=$(echo "$dirList" | sed -e "s@${wildcard}[^:]*:@@g") done # split on ':' (and on space as well to avoid any surprises) @@ -97,13 +110,13 @@ do if [ -e "$dir" ] then #- no duplicate dirs - duplicate=`echo " $dirList " | sed -ne "s@ $dir @DUP@p"` + duplicate=$(echo " $dirList " | sed -ne "s@ $dir @DUP@p") if [ ! "$duplicate" ] then dirList="$dirList $dir" fi - elif [ "$strip" != "true" ] + elif [ "$strip" != true ] then # Print non-existing directories if not in 'strip' mode. dirList="$dirList $dir" diff --git a/etc/aliases.csh b/etc/aliases.csh index fd7f183a368a39d2d60c7ba5d758bbc1af03a0f5..28d4a13975d8554b9aae3489fc8774e57c159a70 100644 --- a/etc/aliases.csh +++ b/etc/aliases.csh @@ -46,16 +46,28 @@ alias wmSchedOFF 'unsetenv WM_SCHEDULER' # Change directory aliases # ~~~~~~~~~~~~~~~~~~~~~~~~ -alias src 'cd $FOAM_SRC' -alias lib 'cd $FOAM_LIB' -alias run 'cd $FOAM_RUN' alias foam 'cd $WM_PROJECT_DIR' -alias foamsrc 'cd $FOAM_SRC/$WM_PROJECT' +alias src 'cd $FOAM_SRC' +alias foamsrc 'cd $FOAM_SRC/OpenFOAM' alias foamfv 'cd $FOAM_SRC/finiteVolume' +alias foam3rdParty 'cd $WM_THIRD_PARTY_DIR' + alias app 'cd $FOAM_APP' -alias util 'cd $FOAM_UTILITIES' +alias lib 'cd $FOAM_LIB' +alias run 'cd $FOAM_RUN' alias sol 'cd $FOAM_SOLVERS' alias tut 'cd $FOAM_TUTORIALS' -alias foam3rdParty 'cd $WM_THIRD_PARTY_DIR' +alias util 'cd $FOAM_UTILITIES' + +# more consistent naming convention +alias foamApps 'cd $FOAM_APP' +alias foamLib 'cd $FOAM_LIB' +alias foamRun 'cd $FOAM_RUN' +alias foamSol 'cd $FOAM_SOLVERS' +alias foamTut 'cd $FOAM_TUTORIALS' +alias foamUtils 'cd $FOAM_UTILITIES' + +alias userApps 'cd $WM_PROJECT_USER_DIR/applications' +alias whichFoam 'echo $WM_PROJECT_DIR' # ----------------------------------------------------------------------------- diff --git a/etc/aliases.sh b/etc/aliases.sh index b193802246982261a6a18ade4442d2ed3cd5f036..3eb87fbc0c94a816e5d5dc28477850a9fb702a0a 100644 --- a/etc/aliases.sh +++ b/etc/aliases.sh @@ -46,16 +46,28 @@ alias wmSchedOFF='unset WM_SCHEDULER' # Change directory aliases # ~~~~~~~~~~~~~~~~~~~~~~~~ -alias src='cd $FOAM_SRC' -alias lib='cd $FOAM_LIB' -alias run='cd $FOAM_RUN' alias foam='cd $WM_PROJECT_DIR' -alias foamsrc='cd $FOAM_SRC/$WM_PROJECT' +alias src='cd $FOAM_SRC' +alias foamsrc='cd $FOAM_SRC/OpenFOAM' alias foamfv='cd $FOAM_SRC/finiteVolume' +alias foam3rdParty='cd $WM_THIRD_PARTY_DIR' + alias app='cd $FOAM_APP' -alias util='cd $FOAM_UTILITIES' +alias lib='cd $FOAM_LIB' +alias run='cd $FOAM_RUN' alias sol='cd $FOAM_SOLVERS' alias tut='cd $FOAM_TUTORIALS' -alias foam3rdParty='cd $WM_THIRD_PARTY_DIR' +alias util='cd $FOAM_UTILITIES' + +# more consistent naming convention +alias foamApps='cd $FOAM_APP' +alias foamLib='cd $FOAM_LIB' +alias foamRun='cd $FOAM_RUN' +alias foamSol='cd $FOAM_SOLVERS' +alias foamTut='cd $FOAM_TUTORIALS' +alias foamUtils='cd $FOAM_UTILITIES' + +alias userApps='cd $WM_PROJECT_USER_DIR/applications' +alias whichFoam='echo $WM_PROJECT_DIR' # -----------------------------------------------------------------------------