Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#! /bin/sh -
# idiomatic parameter and option handling in sh
while test $# -gt 0
do
case "$1" in
--opt1) echo "option 1"
;;
--opt2) echo "option 2"
;;
--*) echo "bad option $1"
;;
*) echo "argument $1"
;;
esac
shift
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment