Skip to content
Snippets Groups Projects

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

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