mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
- foamExec was removed as part of commit 6c68c34e1a but
overlooked the fact that it is partly still needed by foamJob.
When running in parallel, it is used to source the etc/bashrc env.
Reinstated a stripped down form, which has been relocated to
bin/tools directory (it should not be directly called by the user).
The previous version switching functionality has nonetheless be
dropped since it only worked only when a rigid naming convention for
OpenFOAM installations was followed.
ENH: add foamJob log=, -log-app, -no-log options, improved coding quality
This commit is contained in:
committed by
Andrew Heather
parent
7443011217
commit
b6eeaf5155
316
bin/foamJob
316
bin/foamJob
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# | Copyright (C) 2011-2015 OpenFOAM Foundation
|
# | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -32,6 +32,9 @@
|
|||||||
# Redirects the output to 'log' in the case directory.
|
# Redirects the output to 'log' in the case directory.
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
# If dispatching via foamExec
|
||||||
|
foamExec="$WM_PROJECT_DIR/bin/tools/foamExec"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
exec 1>&2
|
exec 1>&2
|
||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
@ -40,80 +43,30 @@ usage() {
|
|||||||
Usage: ${0##*/} [OPTION] <application> ...
|
Usage: ${0##*/} [OPTION] <application> ...
|
||||||
options:
|
options:
|
||||||
-case <dir> specify alternative case directory, default is the cwd
|
-case <dir> specify alternative case directory, default is the cwd
|
||||||
-parallel parallel run of processors
|
-parallel run in parallel (with mpirun)
|
||||||
-screen also sends output to screen
|
-screen also send output to screen
|
||||||
-append append to log file instead of overwriting it
|
-append append to existing log file instead of overwriting it
|
||||||
|
-log=FILE specify the log file
|
||||||
|
-log-app Use log.{appName} for the log file
|
||||||
|
-no-check run without fewer checks (eg, processor dirs etc)
|
||||||
|
-no-log run without log file
|
||||||
-wait wait for execution to complete (when not using -screen)
|
-wait wait for execution to complete (when not using -screen)
|
||||||
-version=VER specify an alternative OpenFOAM version
|
|
||||||
-help print the usage
|
-help print the usage
|
||||||
|
|
||||||
* run an OpenFOAM job in background.
|
Run an OpenFOAM job in background, redirecting output to a 'log' file
|
||||||
Redirects the output to 'log' in the case directory
|
in the case directory
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Echo strings that have single quotes
|
#------------------------------------------------------------------------------
|
||||||
echoArgs() {
|
|
||||||
addSpace=""
|
|
||||||
|
|
||||||
for stringItem in "$@"
|
|
||||||
do
|
|
||||||
echo -n "${addSpace}"
|
|
||||||
|
|
||||||
if [ "${stringItem##* }" = "$stringItem" ]
|
|
||||||
then
|
|
||||||
echo -n "$stringItem"
|
|
||||||
addSpace=" "
|
|
||||||
else
|
|
||||||
echo -n "'$stringItem'"
|
|
||||||
addSpace=" "
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
unset stringItem addSpace
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Replacement for possibly buggy 'which'
|
|
||||||
findExec() {
|
|
||||||
case "$1" in
|
|
||||||
*/*)
|
|
||||||
if [ -x "$1" ]
|
|
||||||
then
|
|
||||||
echo "$1"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
oldIFS=$IFS
|
|
||||||
IFS=':'
|
|
||||||
for d in $PATH
|
|
||||||
do
|
|
||||||
# echo "testing: $d/$1" 1>&2
|
|
||||||
if [ -x "$d/$1" -a ! -d "$d/$1" ]
|
|
||||||
then
|
|
||||||
# echo "Found exec: $d/$1" 1>&2
|
|
||||||
IFS=$oldIFS
|
|
||||||
echo "$d/$1"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
IFS=$oldIFS
|
|
||||||
echo ""
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Main script
|
|
||||||
#~~~~~~~~~~~~
|
|
||||||
unset parallelOpt screenOpt waitOpt
|
|
||||||
unset projectVersion
|
|
||||||
|
|
||||||
# Parse options
|
# Parse options
|
||||||
|
|
||||||
|
logFile="log"
|
||||||
|
optCheck=true
|
||||||
|
unset optParallel optScreen optWait logMode
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -122,27 +75,41 @@ do
|
|||||||
;;
|
;;
|
||||||
-case)
|
-case)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-p | -parallel)
|
-p | -parallel)
|
||||||
parallelOpt=true
|
optParallel=true
|
||||||
;;
|
;;
|
||||||
-s | -screen)
|
-s | -screen)
|
||||||
screenOpt=true
|
optScreen=true
|
||||||
;;
|
;;
|
||||||
-a | -append)
|
-a | -append)
|
||||||
appendOpt=true
|
logMode=append
|
||||||
;;
|
;;
|
||||||
-w | -wait)
|
-w | -wait)
|
||||||
waitOpt=true
|
optWait=true
|
||||||
|
;;
|
||||||
|
-no-check*)
|
||||||
|
unset optCheck
|
||||||
|
;;
|
||||||
|
-no-log)
|
||||||
|
logMode=none
|
||||||
|
logFile=log # Consistency if -append toggles it back on
|
||||||
|
;;
|
||||||
|
-log=*)
|
||||||
|
logFile="${1##*=}"
|
||||||
|
[ -n "$logFile" ] || logFile="log"
|
||||||
|
;;
|
||||||
|
-log-app)
|
||||||
|
logFile="{LOG_APPNAME}" # Tag for log.appName output
|
||||||
;;
|
;;
|
||||||
-version=*)
|
-version=*)
|
||||||
projectVersion="${1#*=}" # for foamExec
|
echo "Ignoring version option" 1>&2
|
||||||
;;
|
;;
|
||||||
-v | -version)
|
-v | -version)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
projectVersion="$2" # for foamExec
|
echo "Ignoring version option" 1>&2
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
@ -166,65 +133,74 @@ done
|
|||||||
# The requested application
|
# The requested application
|
||||||
appName="$1"
|
appName="$1"
|
||||||
|
|
||||||
# Use foamExec for a specified version
|
# Does application even exist?
|
||||||
# Also need foamExec for remote (parallel) runs
|
APPLICATION="$(command -v "$appName")" || \
|
||||||
if [ -n "$projectVersion" -o "$parallelOpt" = true ]
|
usage "Application '$appName' not found"
|
||||||
|
|
||||||
|
if [ "$logFile" = "{LOG_APPNAME}" ]
|
||||||
then
|
then
|
||||||
# When possible, determine if application even exists
|
logFile="log.${appName##*/}"
|
||||||
if [ -z "$projectVersion" ]
|
fi
|
||||||
then
|
|
||||||
findExec "$appName" >/dev/null || usage "Application '$appName' not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
# Need foamExec for remote (parallel) runs
|
||||||
|
if [ "$optParallel" = true ]
|
||||||
|
then
|
||||||
# Use foamExec for dispatching
|
# Use foamExec for dispatching
|
||||||
APPLICATION=$(findExec foamExec) || usage "'foamExec' not found"
|
[ -x "$foamExec" ] || usage "File not found: $foamExec"
|
||||||
|
|
||||||
[ -n "$projectVersion" ] && APPLICATION="$APPLICATION -version $projectVersion"
|
|
||||||
|
|
||||||
|
APPLICATION="$foamExec"
|
||||||
else
|
else
|
||||||
APPLICATION=$(findExec "$appName") || usage "Application '$appName' not found"
|
# Drop first argument in favour of fully qualified APPLICATION
|
||||||
echo "Application : $appName"
|
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$parallelOpt" = true ]
|
# Stringify args, adding single quotes for args with spaces
|
||||||
then
|
echoArgs()
|
||||||
# parallel
|
{
|
||||||
# ~~~~~~~~
|
unset stringifiedArgs
|
||||||
|
|
||||||
|
for stringItem in "$@"
|
||||||
|
do
|
||||||
|
case "$stringItem" in (*' '*) stringItem="'$stringItem'" ;; esac
|
||||||
|
stringifiedArgs="${stringifiedArgs}${stringifiedArgs:+ }${stringItem}"
|
||||||
|
done
|
||||||
|
echo "$stringifiedArgs"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$optParallel" = true ]
|
||||||
|
then
|
||||||
#
|
#
|
||||||
# Check if the case decomposed
|
# Parallel
|
||||||
#
|
#
|
||||||
if [ -r "processor0" -o -r "processors" ]
|
dict="system/decomposeParDict"
|
||||||
|
|
||||||
|
[ -r "$dict" ] || {
|
||||||
|
echo "No $dict found, which is required for parallel running."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
nProcs="$(foamDictionary -entry numberOfSubdomains -value $dict 2>/dev/null)"
|
||||||
|
|
||||||
|
# Check if case is decomposed
|
||||||
|
if [ "$optCheck" = true ]
|
||||||
then
|
then
|
||||||
nprocs="$(foamDictionary -entry numberOfSubdomains -value system/decomposeParDict 2>/dev/null)"
|
[ -r "processor0" ] || [ -r "processors" ] || {
|
||||||
else
|
echo "Case is not currently decomposed"
|
||||||
echo "Case is not currently decomposed"
|
echo "Try decomposing first with \"foamJob decomposePar\""
|
||||||
if [ -r system/decomposeParDict ]
|
|
||||||
then
|
|
||||||
echo "system/decomposeParDict exists"
|
|
||||||
echo "Try decomposing with \"foamJob decomposePar\""
|
|
||||||
exit 1
|
exit 1
|
||||||
else
|
}
|
||||||
echo "Cannot find system/decomposeParDict file required to decompose the case for parallel running."
|
|
||||||
echo "Please consult the User Guide for details of parallel running"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
# Locate mpirun
|
||||||
# Find mpirun
|
mpirun=$(command -v mpirun) || usage "'mpirun' not found"
|
||||||
#
|
mpiopts="-n $nProcs"
|
||||||
mpirun=$(findExec mpirun) || usage "'mpirun' not found"
|
|
||||||
mpiopts="-np $nprocs"
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check if the machine ready to run parallel
|
# Check if the machine ready to run parallel
|
||||||
#
|
|
||||||
echo "Parallel processing using $WM_MPLIB with $nprocs processors"
|
|
||||||
case "$WM_MPLIB" in
|
case "$WM_MPLIB" in
|
||||||
*OPENMPI)
|
*OPENMPI*)
|
||||||
# Add hostfile info
|
# Add hostfile info
|
||||||
for hostfile in \
|
for hostfile in \
|
||||||
hostfile \
|
hostfile \
|
||||||
@ -233,7 +209,7 @@ then
|
|||||||
system/machines \
|
system/machines \
|
||||||
;
|
;
|
||||||
do
|
do
|
||||||
if [ -r $hostfile ]
|
if [ -r "$hostfile" ]
|
||||||
then
|
then
|
||||||
mpiopts="$mpiopts -hostfile $hostfile"
|
mpiopts="$mpiopts -hostfile $hostfile"
|
||||||
break
|
break
|
||||||
@ -242,59 +218,107 @@ then
|
|||||||
|
|
||||||
# Send FOAM_SETTINGS to parallel processes, so that the proper
|
# Send FOAM_SETTINGS to parallel processes, so that the proper
|
||||||
# definitions are sent as well.
|
# definitions are sent as well.
|
||||||
mpiopts="$mpiopts -x FOAM_SETTINGS"
|
if [ -n "$FOAM_SETTINGS" ]
|
||||||
|
then
|
||||||
|
mpiopts="$mpiopts -x FOAM_SETTINGS"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
#
|
#
|
||||||
# Run (in parallel)
|
# Run (in parallel)
|
||||||
#
|
#
|
||||||
if [ "$screenOpt" = true ]
|
echo "Application : $appName ($nProcs processes)"
|
||||||
|
if [ "$logMode" != "none" ]
|
||||||
then
|
then
|
||||||
[ "$appendOpt" = true ] && teeOpts=" -a"
|
echo "Output : $logFile"
|
||||||
echo "Executing: $mpirun $mpiopts $APPLICATION $(echoArgs "$@") -parallel | tee $teeOpts log"
|
fi
|
||||||
$mpirun $mpiopts $APPLICATION "$@" -parallel | tee $teeOpts log
|
echo "Executing : $mpirun $mpiopts $APPLICATION $(echoArgs "$@") -parallel"
|
||||||
|
if [ "$optScreen" = true ]
|
||||||
|
then
|
||||||
|
case "$logMode" in
|
||||||
|
none)
|
||||||
|
"$mpirun" $mpiopts "$APPLICATION" "$@" -parallel
|
||||||
|
;;
|
||||||
|
append)
|
||||||
|
"$mpirun" $mpiopts "$APPLICATION" "$@" -parallel | tee -a "$logFile"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
"$mpirun" $mpiopts "$APPLICATION" "$@" -parallel | tee "$logFile"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
if [ "$appendOpt" = true ]
|
case "$logMode" in
|
||||||
then
|
none)
|
||||||
echo "Executing: $mpirun $mpiopts $APPLICATION $(echoArgs "$@") -parallel >> log 2>&1"
|
"$mpirun" $mpiopts "$APPLICATION" "$@" -parallel > /dev/null 2>&1 &
|
||||||
$mpirun $mpiopts $APPLICATION "$@" -parallel >> log 2>&1 &
|
;;
|
||||||
else
|
append)
|
||||||
echo "Executing: $mpirun $mpiopts $APPLICATION $(echoArgs "$@") -parallel > log 2>&1"
|
"$mpirun" $mpiopts "$APPLICATION" "$@" -parallel >> "$logFile" 2>&1 &
|
||||||
$mpirun $mpiopts $APPLICATION "$@" -parallel > log 2>&1 &
|
;;
|
||||||
fi
|
*)
|
||||||
|
"$mpirun" $mpiopts "$APPLICATION" "$@" -parallel > "$logFile" 2>&1 &
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
pid=$!
|
pid=$!
|
||||||
if [ "$waitOpt" = true ]
|
if [ "$optWait" = true ]
|
||||||
then
|
then
|
||||||
wait $pid
|
echo "Waiting for process $pid to finish"
|
||||||
|
wait "$pid"
|
||||||
|
echo "Process $pid finished"
|
||||||
|
else
|
||||||
|
echo "Process id : $pid"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
#
|
#
|
||||||
# Run (on single processor)
|
# Serial
|
||||||
#
|
#
|
||||||
if [ "$screenOpt" = true ]
|
echo "Application : $appName ($nProcs processes)"
|
||||||
|
if [ "$logMode" != "none" ]
|
||||||
then
|
then
|
||||||
[ "$appendOpt" = true ] && teeOpts=" -a"
|
echo "Output : $logFile"
|
||||||
echo "Executing: $APPLICATION $(echoArgs "$@") | tee $teeOpts log &"
|
fi
|
||||||
$APPLICATION "$@" | tee $teeOpts log &
|
echo "Executing : $APPLICATION $(echoArgs "$@")"
|
||||||
wait $!
|
if [ "$optScreen" = true ]
|
||||||
else
|
then
|
||||||
if [ "$appendOpt" = true ]
|
case "$logMode" in
|
||||||
then
|
none)
|
||||||
echo "Executing: $APPLICATION $(echoArgs "$@") >> log 2>&1 &"
|
"$APPLICATION" "$@" &
|
||||||
$APPLICATION "$@" >> log 2>&1 &
|
;;
|
||||||
else
|
append)
|
||||||
echo "Executing: $APPLICATION $(echoArgs "$@") > log 2>&1 &"
|
"$APPLICATION" "$@" | tee -a "$logFile" &
|
||||||
$APPLICATION "$@" > log 2>&1 &
|
;;
|
||||||
fi
|
*)
|
||||||
|
"$APPLICATION" "$@" | tee "$logFile" &
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
pid=$!
|
pid=$!
|
||||||
if [ "$waitOpt" = true ]
|
echo "Process id : $pid"
|
||||||
|
wait "$pid"
|
||||||
|
else
|
||||||
|
case "$logMode" in
|
||||||
|
none)
|
||||||
|
"$APPLICATION" "$@" > /dev/null 2>&1 &
|
||||||
|
;;
|
||||||
|
append)
|
||||||
|
"$APPLICATION" "$@" >> "$logFile" 2>&1 &
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
"$APPLICATION" "$@" > "$logFile" 2>&1 &
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
pid=$!
|
||||||
|
if [ "$optWait" = true ]
|
||||||
then
|
then
|
||||||
wait $pid
|
echo "Waiting for process $pid to finish"
|
||||||
|
wait "$pid"
|
||||||
|
echo "Process $pid finished"
|
||||||
|
else
|
||||||
|
echo "Process id : $pid"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
120
bin/tools/foamExec
Executable file
120
bin/tools/foamExec
Executable file
@ -0,0 +1,120 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
# \\ / O peration |
|
||||||
|
# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
# \\/ M anipulation |
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# License
|
||||||
|
# This file is part of OpenFOAM.
|
||||||
|
#
|
||||||
|
# OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
# for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Script
|
||||||
|
# foamExec <application> ...
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Runs an application (with arguments) after first sourcing the OpenFOAM
|
||||||
|
# etc/bashrc file from the project directory
|
||||||
|
#
|
||||||
|
# This script must exist in $WM_PROJECT_DIR/bin/tools
|
||||||
|
#
|
||||||
|
# Can useful for parallel runs. For example,
|
||||||
|
#
|
||||||
|
# mpirun -n <nProcs> \
|
||||||
|
# projectDir/bin/tools/foamExec <simpleFoam> ... -parallel
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
usage() {
|
||||||
|
exec 1>&2
|
||||||
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
|
cat<<USAGE
|
||||||
|
|
||||||
|
Usage: ${0##*/} [OPTION] <application> ...
|
||||||
|
|
||||||
|
options:
|
||||||
|
-help Print the usage
|
||||||
|
|
||||||
|
Runs an application (with arguments) after first sourcing the OpenFOAM
|
||||||
|
etc/bashrc file from the project directory
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Report error and exit
|
||||||
|
die()
|
||||||
|
{
|
||||||
|
exec 1>&2
|
||||||
|
echo
|
||||||
|
echo "Error encountered:"
|
||||||
|
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
|
||||||
|
echo
|
||||||
|
echo "See '$0 -help' for usage"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
toolsDir="${0%/*}" # The bin/tools dir
|
||||||
|
projectDir="${toolsDir%/bin/tools}" # Project dir
|
||||||
|
|
||||||
|
# Parse options
|
||||||
|
while [ "$#" -gt 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
-h | -help*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
die "unknown option: '$1'"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[ "$#" -ge 1 ] || die "No application specified"
|
||||||
|
|
||||||
|
[ -d "$projectDir" ] || {
|
||||||
|
echo "Error: no project dir: $projectDir" 1>&2
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -f "$projectDir/etc/bashrc" ] || {
|
||||||
|
echo "Error: file not found: $projectDir/etc/bashrc" 1>&2
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Source bashrc within a function to preserve command-line arguments
|
||||||
|
# - this will not have aliases, but working non-interactively anyhow
|
||||||
|
sourceBashrc()
|
||||||
|
{
|
||||||
|
. "$projectDir/etc/bashrc" $FOAM_SETTINGS
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceBashrc
|
||||||
|
exec "$@"
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
Reference in New Issue
Block a user