(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"our own option parser">)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[26]) (HereDoc op_id: Redir_DLess fd: -1 body: {("usage: test-parse-options <options>\n") ("\n") (" --yes get a boolean\n") (" -D, --no-doubt begins with 'no-'\n") (" -B, --no-fear be brave\n") (" -b, --boolean increment by one\n") (" -4, --or4 bitwise-or boolean with ...0100\n") (" --neg-or4 same as --no-or4\n") ("\n") (" -i, --integer <n> get a integer\n") (" -j <n> get a integer, too\n") (" -m, --magnitude <n> get a magnitude\n") (" --set23 set integer to 23\n") (" -t <time> get timestamp of <time>\n") (" -L, --length <str> get length of <str>\n") (" -F, --file <file> set file to <file>\n") ("\n") ("String options\n") (" -s, --string <string>\n") (" get a string\n") (" --string2 <str> get another string\n") (" --st <st> get another string (pervert ordering)\n") (" -o <str> get another string\n") (" --list <str> add str to list\n") ("\n") ("Magic arguments\n") (" --quux means --quux\n") (" -NUM set integer to NUM\n") (" + same as -b\n") (" --ambiguous positive ambiguity\n") (" --no-ambiguous negative ambiguity\n") ("\n") ("Standard options\n") (" --abbrev[=<n>] use <n> digits to display SHA-1s\n") (" -v, --verbose be verbose\n") (" -n, --dry-run dry run\n") (" -q, --quiet be quiet\n") (" --expect <string> expected output in the variable dump\n") ("\n") } do_expansion: False here_end: EOF was_filled: True spids: [29] ) ] ) (C {(test_expect_success)} {(SQ <"test help">)} { (SQ <"\n"> <"\ttest_must_fail test-parse-options -h >output 2>output.err &&\n"> <"\ttest_must_be_empty output.err &&\n"> <"\ttest_i18ncmp expect output\n"> ) } ) (C {(mv)} {(expect)} {(expect.err)}) (FuncDef name: check body: (BraceGroup children: [ (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:what) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [63] ) ] spids: [63] ) (AndOr children: [ (C {(shift)}) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:expect) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [76] ) ] spids: [76] ) (AndOr children: [ (C {(shift)}) (C {(test-parse-options)} {(--expect) (Lit_Other "=") (DQ ($ VSub_Name "$what") (" ") ($ VSub_Name "$expect")) } {(DQ ($ VSub_At "$@"))} ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [60] ) spids: [55 59] ) (FuncDef name: check_unknown_i18n body: (BraceGroup children: [ (AndOr children: [ (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list: [{(--) (Lit_Other "*")}] action: [ (SimpleCommand words: [ {(echo)} {(error) (Lit_Other ":")} {(unknown)} {(option)} {(EscapedLiteralPart token:<Lit_EscapedChar "\\`">) (BracedVarSub token: <VSub_Number 1> suffix_op: (StringUnary op_id:VOp1_Pound arg_word:{(--)}) spids: [137 141] ) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) } ] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[144])] ) ] spids: [122 124 147 -1] ) (case_arm pat_list: [{(-) (Lit_Other "*")}] action: [ (SimpleCommand words: [ {(echo)} {(error) (Lit_Other ":")} {(unknown)} {(switch)} {(EscapedLiteralPart token:<Lit_EscapedChar "\\`">) (BracedVarSub token: <VSub_Number 1> suffix_op: (StringUnary op_id:VOp1_Pound arg_word:{(-)}) spids: [165 169] ) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) } ] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[172])] ) ] spids: [150 152 175 -1] ) ] spids: [113 119 178] ) (AndOr children: [ (SimpleCommand words: [{(cat)} {(expect.err)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{(expect)} spids:[187])] ) (AndOr children: [ (SimpleCommand words: [{(test_must_fail)} {(test-parse-options)} {($ VSub_Star "$*")}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(output)} spids: [199] ) (Redir op_id: Redir_Great fd: 2 arg_word: {(output.err)} spids: [202] ) ] ) (AndOr children: [ (C {(test_must_be_empty)} {(output)}) (C {(test_i18ncmp)} {(expect)} {(output.err)}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [110] ) spids: [106 109] ) (C {(test_expect_success)} {(SQ <"OPT_BOOL() #1">)} {(SQ <"check boolean: 1 --yes">)}) (C {(test_expect_success)} {(SQ <"OPT_BOOL() #2">)} {(SQ <"check boolean: 1 --no-doubt">)}) (C {(test_expect_success)} {(SQ <"OPT_BOOL() #3">)} {(SQ <"check boolean: 1 -D">)}) (C {(test_expect_success)} {(SQ <"OPT_BOOL() #4">)} {(SQ <"check boolean: 1 --no-fear">)}) (C {(test_expect_success)} {(SQ <"OPT_BOOL() #5">)} {(SQ <"check boolean: 1 -B">)}) (C {(test_expect_success)} {(SQ <"OPT_BOOL() is idempotent #1">)} {(SQ <"check boolean: 1 --yes --yes">)} ) (C {(test_expect_success)} {(SQ <"OPT_BOOL() is idempotent #2">)} {(SQ <"check boolean: 1 -DB">)}) (C {(test_expect_success)} {(SQ <"OPT_BOOL() negation #1">)} {(SQ <"check boolean: 0 -D --no-yes">)}) (C {(test_expect_success)} {(SQ <"OPT_BOOL() negation #2">)} {(SQ <"check boolean: 0 -D --no-no-doubt">)} ) (C {(test_expect_success)} {(SQ <"OPT_BOOL() no negation #1">)} {(SQ <"check_unknown_i18n --fear">)}) (C {(test_expect_success)} {(SQ <"OPT_BOOL() no negation #2">)} {(SQ <"check_unknown_i18n --no-no-fear">)} ) (C {(test_expect_success)} {(SQ <"OPT_BOOL() positivation">)} {(SQ <"check boolean: 0 -D --doubt">)}) (C {(test_expect_success)} {(SQ <"OPT_INT() negative">)} {(SQ <"check integer: -2345 -i -2345">)}) (C {(test_expect_success)} {(SQ <"OPT_MAGNITUDE() simple">)} {(SQ <"\n"> <"\tcheck magnitude: 2345678 -m 2345678\n">)} ) (C {(test_expect_success)} {(SQ <"OPT_MAGNITUDE() kilo">)} {(SQ <"\n"> <"\tcheck magnitude: 239616 -m 234k\n">)} ) (C {(test_expect_success)} {(SQ <"OPT_MAGNITUDE() mega">)} {(SQ <"\n"> <"\tcheck magnitude: 104857600 -m 100m\n">)} ) (C {(test_expect_success)} {(SQ <"OPT_MAGNITUDE() giga">)} {(SQ <"\n"> <"\tcheck magnitude: 1073741824 -m 1g\n">)} ) (C {(test_expect_success)} {(SQ <"OPT_MAGNITUDE() 3giga">)} {(SQ <"\n"> <"\tcheck magnitude: 3221225472 -m 3g\n">)} ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[422]) (HereDoc op_id: Redir_DLess fd: -1 body: {("boolean: 2\n") ("integer: 1729\n") ("magnitude: 16384\n") ("timestamp: 0\n") ("string: 123\n") ("abbrev: 7\n") ("verbose: 2\n") ("quiet: 0\n") ("dry run: yes\n") ("file: prefix/my.file\n") } do_expansion: False here_end: EOF was_filled: True spids: [425] ) ] ) (C {(test_expect_success)} {(SQ <"short options">)} { (SQ <"\n"> <"\ttest-parse-options -s123 -b -i 1729 -m 16k -b -vv -n -F my.file \\\n"> <"\t>output 2>output.err &&\n"> <"\ttest_cmp expect output &&\n"> <"\ttest_must_be_empty output.err\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[447]) (HereDoc op_id: Redir_DLess fd: -1 body: {("boolean: 2\n") ("integer: 1729\n") ("magnitude: 16384\n") ("timestamp: 0\n") ("string: 321\n") ("abbrev: 10\n") ("verbose: 2\n") ("quiet: 0\n") ("dry run: no\n") ("file: prefix/fi.le\n") } do_expansion: False here_end: EOF was_filled: True spids: [450] ) ] ) (C {(test_expect_success)} {(SQ <"long options">)} { (SQ <"\n"> <"\ttest-parse-options --boolean --integer 1729 --magnitude 16k \\\n"> <"\t\t--boolean --string2=321 --verbose --verbose --no-dry-run \\\n"> <"\t\t--abbrev=10 --file fi.le --obsolete \\\n"> <"\t\t>output 2>output.err &&\n"> <"\ttest_must_be_empty output.err &&\n"> <"\ttest_cmp expect output\n"> ) } ) (C {(test_expect_success)} {(SQ <"missing required value">)} { (SQ <"\n"> <"\ttest_expect_code 129 test-parse-options -s &&\n"> <"\ttest_expect_code 129 test-parse-options --string &&\n"> <"\ttest_expect_code 129 test-parse-options --file\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[488]) (HereDoc op_id: Redir_DLess fd: -1 body: {("boolean: 1\n") ("integer: 13\n") ("magnitude: 0\n") ("timestamp: 0\n") ("string: 123\n") ("abbrev: 7\n") ("verbose: -1\n") ("quiet: 0\n") ("dry run: no\n") ("file: (not set)\n") ("arg 00: a1\n") ("arg 01: b1\n") ("arg 02: --boolean\n") } do_expansion: False here_end: EOF was_filled: True spids: [491] ) ] ) (C {(test_expect_success)} {(SQ <"intermingled arguments">)} { (SQ <"\n"> <"\ttest-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \\\n"> <"\t\t>output 2>output.err &&\n"> <"\ttest_must_be_empty output.err &&\n"> <"\ttest_cmp expect output\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[513]) (HereDoc op_id: Redir_DLess fd: -1 body: {("boolean: 0\n") ("integer: 2\n") ("magnitude: 0\n") ("timestamp: 0\n") ("string: (not set)\n") ("abbrev: 7\n") ("verbose: -1\n") ("quiet: 0\n") ("dry run: no\n") ("file: (not set)\n") } do_expansion: False here_end: EOF was_filled: True spids: [516] ) ] ) (C {(test_expect_success)} {(SQ <"unambiguously abbreviated option">)} { (SQ <"\n"> <"\ttest-parse-options --int 2 --boolean --no-bo >output 2>output.err &&\n"> <"\ttest_must_be_empty output.err &&\n"> <"\ttest_cmp expect output\n"> ) } ) (C {(test_expect_success)} {(SQ <"unambiguously abbreviated option with \"=\"">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"integer: 2\" --int=2\n">)} ) (C {(test_expect_success)} {(SQ <"ambiguously abbreviated option">)} {(SQ <"\n"> <"\ttest_expect_code 129 test-parse-options --strin 123\n">)} ) (C {(test_expect_success)} {(SQ <"non ambiguous option (after two options it abbreviates)">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"string: 123\" --st 123\n">)} ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(typo.err)} spids:[573]) (HereDoc op_id: Redir_DLess fd: -1 body: {("error: did you mean `--boolean` (with two dashes ?)\n")} do_expansion: False here_end: EOF was_filled: True spids: [576] ) ] ) (C {(test_expect_success)} {(SQ <"detect possible typos">)} { (SQ <"\n"> <"\ttest_must_fail test-parse-options -boolean >output 2>output.err &&\n"> <"\ttest_must_be_empty output &&\n"> <"\ttest_cmp typo.err output.err\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(typo.err)} spids:[597]) (HereDoc op_id: Redir_DLess fd: -1 body: {("error: did you mean `--ambiguous` (with two dashes ?)\n")} do_expansion: False here_end: EOF was_filled: True spids: [600] ) ] ) (C {(test_expect_success)} {(SQ <"detect possible typos">)} { (SQ <"\n"> <"\ttest_must_fail test-parse-options -ambiguous >output 2>output.err &&\n"> <"\ttest_must_be_empty output &&\n"> <"\ttest_cmp typo.err output.err\n"> ) } ) (C {(test_expect_success)} {(SQ <"keep some options as arguments">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"arg 00: --quux\" --quux\n">)} ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[633]) (HereDoc op_id: Redir_DLess fd: -1 body: {("boolean: 0\n") ("integer: 0\n") ("magnitude: 0\n") ("timestamp: 1\n") ("string: (not set)\n") ("abbrev: 7\n") ("verbose: -1\n") ("quiet: 1\n") ("dry run: no\n") ("file: (not set)\n") ("arg 00: foo\n") } do_expansion: False here_end: EOF was_filled: True spids: [636] ) ] ) (C {(test_expect_success)} {(SQ <"OPT_DATE() works">)} { (SQ <"\n"> <"\ttest-parse-options -t \"1970-01-01 00:00:01 +0000\" \\\n"> <"\t\tfoo -q >output 2>output.err &&\n"> <"\ttest_must_be_empty output.err &&\n"> <"\ttest_cmp expect output\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[658]) (HereDoc op_id: Redir_DLess fd: -1 body: {("Callback: \"four\", 0\n") ("boolean: 5\n") ("integer: 4\n") ("magnitude: 0\n") ("timestamp: 0\n") ("string: (not set)\n") ("abbrev: 7\n") ("verbose: -1\n") ("quiet: 0\n") ("dry run: no\n") ("file: (not set)\n") } do_expansion: False here_end: EOF was_filled: True spids: [661] ) ] ) (C {(test_expect_success)} {(SQ <"OPT_CALLBACK() and OPT_BIT() work">)} { (SQ <"\n"> <"\ttest-parse-options --length=four -b -4 >output 2>output.err &&\n"> <"\ttest_must_be_empty output.err &&\n"> <"\ttest_cmp expect output\n"> ) } ) (SimpleCommand redirects:[(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[680])]) (C {(test_expect_success)} {(SQ <"OPT_CALLBACK() and callback errors work">)} { (SQ <"\n"> <"\ttest_must_fail test-parse-options --no-length >output 2>output.err &&\n"> <"\ttest_i18ncmp expect output &&\n"> <"\ttest_i18ncmp expect.err output.err\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[700]) (HereDoc op_id: Redir_DLess fd: -1 body: {("boolean: 1\n") ("integer: 23\n") ("magnitude: 0\n") ("timestamp: 0\n") ("string: (not set)\n") ("abbrev: 7\n") ("verbose: -1\n") ("quiet: 0\n") ("dry run: no\n") ("file: (not set)\n") } do_expansion: False here_end: EOF was_filled: True spids: [703] ) ] ) (C {(test_expect_success)} {(SQ <"OPT_BIT() and OPT_SET_INT() work">)} { (SQ <"\n"> <"\ttest-parse-options --set23 -bbbbb --no-or4 >output 2>output.err &&\n"> <"\ttest_must_be_empty output.err &&\n"> <"\ttest_cmp expect output\n"> ) } ) (C {(test_expect_success)} {(SQ <"OPT_NEGBIT() and OPT_SET_INT() work">)} { (SQ <"\n"> <"\ttest-parse-options --set23 -bbbbb --neg-or4 >output 2>output.err &&\n"> <"\ttest_must_be_empty output.err &&\n"> <"\ttest_cmp expect output\n"> ) } ) (C {(test_expect_success)} {(SQ <"OPT_BIT() works">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"boolean: 6\" -bb --or4\n">)} ) (C {(test_expect_success)} {(SQ <"OPT_NEGBIT() works">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"boolean: 6\" -bb --no-neg-or4\n">)} ) (C {(test_expect_success)} {(SQ <"OPT_COUNTUP() with PARSE_OPT_NODASH works">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"boolean: 6\" + + + + + +\n">)} ) (C {(test_expect_success)} {(SQ <"OPT_NUMBER_CALLBACK() works">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"integer: 12345\" -12345\n">)} ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[786]) (HereDoc op_id: Redir_DLess fd: -1 body: {("boolean: 0\n") ("integer: 0\n") ("magnitude: 0\n") ("timestamp: 0\n") ("string: (not set)\n") ("abbrev: 7\n") ("verbose: -1\n") ("quiet: 0\n") ("dry run: no\n") ("file: (not set)\n") } do_expansion: False here_end: EOF was_filled: True spids: [789] ) ] ) (C {(test_expect_success)} {(SQ <"negation of OPT_NONEG flags is not ambiguous">)} { (SQ <"\n"> <"\ttest-parse-options --no-ambig >output 2>output.err &&\n"> <"\ttest_must_be_empty output.err &&\n"> <"\ttest_cmp expect output\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_DGreat fd:-1 arg_word:{(expect)} spids:[810]) (HereDoc op_id: Redir_DLess fd: -1 body: {("list: foo\n") ("list: bar\n") ("list: baz\n")} do_expansion: False here_end: EOF was_filled: True spids: [813] ) ] ) (C {(test_expect_success)} {(SQ <"--list keeps list of strings">)} { (SQ <"\n"> <"\ttest-parse-options --list foo --list=bar --list=baz >output &&\n"> <"\ttest_cmp expect output\n"> ) } ) (C {(test_expect_success)} {(SQ <"--no-list resets list">)} { (SQ <"\n"> <"\ttest-parse-options --list=other --list=irrelevant --list=options \\\n"> <"\t\t--no-list --list=foo --list=bar --list=baz >output &&\n"> <"\ttest_cmp expect output\n"> ) } ) (C {(test_expect_success)} {(SQ <"multiple quiet levels">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"quiet: 3\" -q -q -q\n">)} ) (C {(test_expect_success)} {(SQ <"multiple verbose levels">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"verbose: 3\" -v -v -v\n">)} ) (C {(test_expect_success)} {(SQ <"--no-quiet sets --quiet to 0">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"quiet: 0\" --no-quiet\n">)} ) (C {(test_expect_success)} {(SQ <"--no-quiet resets multiple -q to 0">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"quiet: 0\" -q -q -q --no-quiet\n">)} ) (C {(test_expect_success)} {(SQ <"--no-verbose sets verbose to 0">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"verbose: 0\" --no-verbose\n">)} ) (C {(test_expect_success)} {(SQ <"--no-verbose resets multiple verbose to 0">)} {(SQ <"\n"> <"\ttest-parse-options --expect=\"verbose: 0\" -v -v -v --no-verbose\n">)} ) (C {(test_done)}) ] )