Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiojb/2f479c03722060304519edaac984ad42 to your computer and use it in GitHub Desktop.
Save fabiojb/2f479c03722060304519edaac984ad42 to your computer and use it in GitHub Desktop.
#! /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