Skip to content

Instantly share code, notes, and snippets.

@akaptur
Created October 9, 2014 19:50
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 akaptur/fd24335d81328bbd8de8 to your computer and use it in GitHub Desktop.
Save akaptur/fd24335d81328bbd8de8 to your computer and use it in GitHub Desktop.
test ⚲ ./testopt
aflag = 0, bflag = 0, cvalue = (null)
test ⚲ ./testopt -a -b
aflag = 1, bflag = 1, cvalue = (null)
test ⚲ ./testopt -c
Option -c requires an argument.
test ⚲ ./testopt -ab
aflag = 1, bflag = 1, cvalue = (null)
test ⚲ ./testopt -c foo
aflag = 0, bflag = 0, cvalue = foo
test ⚲ ./testopt -cfoo
aflag = 0, bflag = 0, cvalue = foo
test ⚲ ./testopt arg1
aflag = 0, bflag = 0, cvalue = (null)
Non-option argument arg1
test ⚲ ./testopt -a arg1
aflag = 1, bflag = 0, cvalue = (null)
Non-option argument arg1
test ⚲ ./testopt -c foo arg1
aflag = 0, bflag = 0, cvalue = foo
Non-option argument arg1
test ⚲ ./testopt -a -- -b
aflag = 1, bflag = 0, cvalue = (null)
Non-option argument -b
test ⚲ ./testopt -a -
aflag = 1, bflag = 0, cvalue = (null)
Non-option argument -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment