diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..178c540 --- /dev/null +++ b/setup.sh @@ -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 ] " + echo + echo "-a 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}/ëëë"