Skip to content
Snippets Groups Projects

The help function of the bash scripts was somewhat clunky, and has now been...

Closed Peters, Wouter requested to merge (removed):improve_bash_help into master
2 files
+ 75
60
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 36
27
@@ -14,39 +14,47 @@
#!/bin/bash
set -e
cat > heredocfile.txt <<_EOF_
where <rootdir> is a base folder for the project
where <projectsource> is a source folder for the project, to clone
and <projectclone> is a name to use for the cloned project.
!! A folder rootdir/projectclone will be created !!
_EOF_
while getopts "h" opt; do
case $opt in
h) cat heredocfile.txt
exit 1
;;
\?) echo "Invalid option: -$OPTARG" >&2
exit 1
;;
*) cat heredocfile.txt
exit 1
;;
usage="$basename "$0" [arg1] [arg2] [arg3] [-h]
-- script to clone an existing CTDAS run and take aover all its settings. This allows a run to be forked, or continued separate from its origin
where:
arg1: base directory with original project (i.e., /scratch/"$USER"/)
arg2: original project name (i.e, test_ctdas)
arg3: cloned project name (i.e, real_ctdas_run)
-h shows this help text
! A new folder will then be created and populated:
/scratch/"$USER"/real_ctdas_run/
"
while getopts ':hs:' option; do
case "$option" in
h) echo "$usage"
exit
;;
:) printf "missing argument for -%s\n" "$OPTARG" >&3
echo "$usage" >&3
exit 1
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&3
echo "$usage" >&3
exit 1
;;
esac
done
EXPECTED_ARGS=3
E_BADARGS=666
if [ $# -ne $EXPECTED_ARGS ]
then
echo ""
echo "Usage: `basename $0` rootdir projectsource projectclone"
cat heredocfile.txt
exit $E_BADARGS
if [[ $# -ne $EXPECTED_ARGS ]]; then
printf "Missing arguments to function, need $EXPECTED_ARGS \n\n"
echo "$usage"
exit 2
fi
echo "New project to be started in folder $1"
echo " ...........with name $3"
echo " ...........cloned from $1/$2"
@@ -83,3 +91,4 @@ echo ""
cd ${rundir}
pwd
Loading