script to create test setup
This commit is contained in:
parent
a175e494a1
commit
2936e58e00
1 changed files with 63 additions and 0 deletions
63
setup.sh
Executable file
63
setup.sh
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -u # Throw errors when unset variables are used
|
||||
set -e # Exit on error
|
||||
#set -o pipefail # Bash specific
|
||||
|
||||
usage() {
|
||||
echo "Tool to BLAH BLAH BLAH"
|
||||
echo
|
||||
echo "Usage:"
|
||||
echo "$0 [-eh] [-a <arg>] <blabla>"
|
||||
echo
|
||||
echo "-a <arg> Option with argument"
|
||||
echo "-e Example option"
|
||||
echo "-h This help message"
|
||||
exit
|
||||
}
|
||||
|
||||
askyn() {
|
||||
while true; do
|
||||
printf '%s ' "$1 "
|
||||
read -r yn
|
||||
case $yn in
|
||||
[Yy]* ) return 0;;
|
||||
[Nn]* ) return 1;;
|
||||
* ) echo "Please answer [y]es or [n]o.";;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# A POSIX variable
|
||||
OPTIND=1 # Reset in case getopts has been used previously in the shell.
|
||||
|
||||
# Initialize our own variables:
|
||||
ARGUMENT=""
|
||||
EXAMPLE=""
|
||||
|
||||
# getopts only allows single letter options (but is apparently the most
|
||||
# portable). If you want multi letter options (eg --help) use getopt.
|
||||
while getopts "hea:" opt; do
|
||||
case "$opt" in
|
||||
a) ARGUMENT="$OPTARG";;
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
e) EXAMPLE="-e" ;;
|
||||
?) exit 1 ;; # message provided by getopts
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
[ $# -ge 1 ] && [ "$1" = "--" ] && shift
|
||||
|
||||
MYDIR=$(dirname "$(realpath "$0")")
|
||||
TESTDIR="${MYDIR}/test"
|
||||
|
||||
mkdir -p "${TESTDIR}"
|
||||
rm "${TESTDIR}/*"
|
||||
touch "${TESTDIR}/aaa"
|
||||
touch "${TESTDIR}/bbb"
|
||||
touch "${TESTDIR}/ccc"
|
||||
touch "${TESTDIR}/ëëë"
|
||||
Loading…
Add table
Add a link
Reference in a new issue