In pure bourne shell...
Code:
f=0
while [ $# -gt 0 ]; do
case "$1" in
-o?*)
# handles things like -oValue
o=`expr "$1" : '..\(.*\)'`
;;
-o)
# handles things like -o Value
o="$2"
shift
;;
-f)
# Just a flag (on/off)
f=1
;;
*)
break
;;
esac
shift
done
echo "o=$o, f=$f"
# Loop through remaining arguments (arguments without a hyphen)
for arg in "$@"; do
echo "$arg"
done