Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
required arguments shell
#!/bin/sh
set -e
set -o pipefail
while [[ "$#" > 0 ]]; do case $1 in
-f|--from) shift; FROM=$1;;
-t|--to) shift; TO=$1;;
-d|--dest) shift; DEST=$1;;
*) echo "Unknown parameter passed: $1"; exit 1;;
esac; shift; done
required=( FROM TO DEST)
for i in "${required[@]}"
do
if [[ -z ${!i} ]]; then
echo "required arg $i was not passed"
exit 1;
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.