===== CASE: -n -c FOO=1 break ===== FOO=1 break ^~~~ [ -c flag ]:1: Control flow shouldn't have environment bindings ===== CASE: -n -c break 1 2 ===== break 1 2 ^ [ -c flag ]:1: Unexpected argument to 'break' ===== CASE: -n -c x"y"() { echo hi; } ===== x"y"() { echo hi; } ^ [ -c flag ]:1: Invalid function name ===== CASE: -n -c function x"y" { echo hi; } ===== function x"y" { echo hi; } ^ [ -c flag ]:1: Invalid KSH-style function name ===== CASE: -n -c } ===== } ^ [ -c flag ]:1: Unexpected right brace ===== CASE: -n -c case foo in *) echo ===== case foo in *) echo ^ [ -c flag ]:1: Expected ;; or esac ===== CASE: -n -c case foo in x|) echo ===== case foo in x|) echo ^ [ -c flag ]:1: Expected case pattern ===== CASE: -n -c ls foo| ===== ls foo| ^ [ -c flag ]:1: Unexpected EOF while parsing command ===== CASE: -n -c ls foo&& ===== ls foo&& ^ [ -c flag ]:1: Unexpected EOF while parsing command ===== CASE: -n -c foo() ===== foo() ^ [ -c flag ]:1: Unexpected word while parsing compound command ===== CASE: -n -c break >out ===== (command.ControlFlow keyword: (Token id: Id.ControlFlow_Break col: 0 length: 5 span_id: 0 line: (SourceLine line_num:1 content:"break >out" src:(source.CFlag)) tval: break ) ) ===== CASE: -n -c break >out ===== break >out ^~~~~ [ -c flag ]:1: Control flow shouldn't have redirects ===== CASE: -n -c [ ( x ] ===== [ ( x ] ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_RBracket) ===== CASE: -n -c PYTHONPATH=. FOO=(1 2) python ===== PYTHONPATH=. FOO=(1 2) python ^~~~ [ -c flag ]:1: Environment bindings can't contain array literals ===== CASE: -n -c PYTHONPATH+=1 python ===== PYTHONPATH+=1 python ^~~~~~~~~~~~ [ -c flag ]:1: Expected = in environment binding, got += ===== CASE: -n -c =var ===== =var ^ [ -c flag ]:1: =word isn't allowed. Hint: add a space after =, or quote it ===== CASE: -n -c =f(x) ===== =f(x) ^ [ -c flag ]:1: =word isn't allowed. Hint: add a space after =, or quote it ===== CASE: -n -c =var ===== =var ^ [ -c flag ]:1: =word isn't allowed. Hint: add a space after =, or quote it ===== CASE: -n -c =f(x) ===== =f(x) ^ [ -c flag ]:1: =word isn't allowed. Hint: add a space after =, or quote it ===== CASE: -n -c echo line 2 echo $( echo ===== echo $( echo ^ [ -c flag ]:3: Invalid word while parsing command list ===== CASE: -n -c echo line 2 echo ` echo ===== echo ` echo ^ [ -c flag ]:3: Unexpected EOF while looking for closing backtick ===== CASE: -n -c echo line 2 echo ` echo \` ===== echo ` echo \` ^ [ -c flag ]:3: Unexpected EOF while looking for closing backtick ===== CASE: -n -c echo line 2 echo ` echo \`unclosed ` ===== echo ` echo \`unclosed ` ^ [ backticks in [ -c flag ] ]:3: Unexpected EOF while looking for closing backtick ===== CASE: -n -c echo `for x in` ===== echo `for x in` ^ [ backticks in [ -c flag ] ]:1: Invalid word in for loop ===== CASE: -n -c echo < << ===== echo < << ^~ [ -c flag ]:1: Invalid token after redirect operator ===== CASE: -n -c echo $( echo > >> ) ===== echo $( echo > >> ) ^~ [ -c flag ]:1: Invalid token after redirect operator ===== CASE: -n -c cat < 0 && 43 > 42)) ===== (command.DParen left: (Token id: Id.Op_DLeftParen col: 0 length: 2 span_id: 0 line: (SourceLine line_num:1 content:"((1 > 0 && 43 > 42))" src:(source.CFlag)) tval: _ ) child: (arith_expr.Binary op_id: Id.Arith_DAmp left: (arith_expr.Binary op_id: Id.Arith_Great left: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 2 length: 1 span_id: 1 line: (SourceLine line_num:1 content:"((1 > 0 && 43 > 42))" src:(source.CFlag)) tval: 1 ) ] ) right: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 6 length: 1 span_id: 5 line: (SourceLine line_num:1 content:"((1 > 0 && 43 > 42))" src:(source.CFlag)) tval: 0 ) ] ) ) right: (arith_expr.Binary op_id: Id.Arith_Great left: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 11 length: 2 span_id: 9 line: (SourceLine line_num:1 content:"((1 > 0 && 43 > 42))" src:(source.CFlag)) tval: 43 ) ] ) right: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 16 length: 2 span_id: 13 line: (SourceLine line_num:1 content:"((1 > 0 && 43 > 42))" src:(source.CFlag)) tval: 42 ) ] ) ) ) right: (Token id: Id.Op_DRightParen col: 19 length: 1 span_id: 15 line: (SourceLine line_num:1 content:"((1 > 0 && 43 > 42))" src:(source.CFlag)) tval: _ ) redirects: [] ) ===== CASE: -n -c ((1 > 0 && 43 > 42)) ===== ((1 > 0 && 43 > 42)) ^~ [ -c flag ]:1: You may want a space between parens (parse_dparen) ===== CASE: -n -c if ((1 > 0 && 43 > 42)); then echo yes; fi ===== (command.If if_kw: (Token id: Id.KW_If col: 0 length: 2 span_id: 0 line: (SourceLine line_num:1 content:"if ((1 > 0 && 43 > 42)); then echo yes; fi" src:(source.CFlag)) tval: if ) arms: [ (IfArm keyword: (Token id: Id.KW_If col: 0 length: 2 span_id: 0 line: (SourceLine line_num:1 content:"if ((1 > 0 && 43 > 42)); then echo yes; fi" src:(source.CFlag)) tval: if ) cond: (condition.Shell commands: [ (command.Sentence child: (command.DParen left: (Token id: Id.Op_DLeftParen col: 3 length: 2 span_id: 2 line: (SourceLine line_num: 1 content: "if ((1 > 0 && 43 > 42)); then echo yes; fi" src: (source.CFlag) ) tval: _ ) child: (arith_expr.Binary op_id: Id.Arith_DAmp left: (arith_expr.Binary op_id: Id.Arith_Great left: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 5 length: 1 span_id: 3 line: (SourceLine line_num: 1 content: "if ((1 > 0 && 43 > 42)); then echo yes; fi" src: (source.CFlag) ) tval: 1 ) ] ) right: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 9 length: 1 span_id: 7 line: (SourceLine line_num: 1 content: "if ((1 > 0 && 43 > 42)); then echo yes; fi" src: (source.CFlag) ) tval: 0 ) ] ) ) right: (arith_expr.Binary op_id: Id.Arith_Great left: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 14 length: 2 span_id: 11 line: (SourceLine line_num: 1 content: "if ((1 > 0 && 43 > 42)); then echo yes; fi" src: (source.CFlag) ) tval: 43 ) ] ) right: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 19 length: 2 span_id: 15 line: (SourceLine line_num: 1 content: "if ((1 > 0 && 43 > 42)); then echo yes; fi" src: (source.CFlag) ) tval: 42 ) ] ) ) ) right: (Token id: Id.Op_DRightParen col: 22 length: 1 span_id: 17 line: (SourceLine line_num: 1 content: "if ((1 > 0 && 43 > 42)); then echo yes; fi" src: (source.CFlag) ) tval: _ ) redirects: [] ) terminator: (Token id: Id.Op_Semi col: 23 length: 1 span_id: 18 line: (SourceLine line_num:1 content:"if ((1 > 0 && 43 > 42)); then echo yes; fi" src:(source.CFlag)) tval: _ ) ) ] ) then_kw: (Token id: Id.KW_Then col: 25 length: 4 span_id: 20 line: (SourceLine line_num:1 content:"if ((1 > 0 && 43 > 42)); then echo yes; fi" src:(source.CFlag)) tval: then ) action: [ (command.Sentence child: (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 30 length: 4 span_id: 22 line: (SourceLine line_num:1 content:"if ((1 > 0 && 43 > 42)); then echo yes; fi" src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 30 length: 4 span_id: 22 line: (SourceLine line_num: 1 content: "if ((1 > 0 && 43 > 42)); then echo yes; fi" src: (source.CFlag) ) tval: echo ) ] ) (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 35 length: 3 span_id: 24 line: (SourceLine line_num: 1 content: "if ((1 > 0 && 43 > 42)); then echo yes; fi" src: (source.CFlag) ) tval: yes ) ] ) ] redirects: [] do_fork: T ) terminator: (Token id: Id.Op_Semi col: 38 length: 1 span_id: 25 line: (SourceLine line_num:1 content:"if ((1 > 0 && 43 > 42)); then echo yes; fi" src:(source.CFlag)) tval: _ ) ) ] spids: [0 20] ) ] else_action: [] fi_kw: (Token id: Id.KW_Fi col: 40 length: 2 span_id: 27 line: (SourceLine line_num:1 content:"if ((1 > 0 && 43 > 42)); then echo yes; fi" src:(source.CFlag)) tval: fi ) redirects: [] ) ===== CASE: -n -c if ((1 > 0 && 43 > 42)); then echo yes; fi ===== if ((1 > 0 && 43 > 42)); then echo yes; fi ^~ [ -c flag ]:1: You may want a space between parens (parse_dparen) ===== CASE: -n -c for ((x = 1; x < 5; ++x)); do echo $x; done ===== (command.ForExpr keyword: (Token id: Id.KW_For col: 0 length: 3 span_id: 0 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: for ) init: (arith_expr.BinaryAssign op_id: Id.Arith_Equal left: (SimpleVarSub left: (Token id: Id.Lit_ArithVarLike col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: x ) var_name: x ) right: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 10 length: 1 span_id: 7 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: 1 ) ] ) ) cond: (arith_expr.Binary op_id: Id.Arith_Less left: (SimpleVarSub left: (Token id: Id.Lit_ArithVarLike col: 13 length: 1 span_id: 10 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: x ) var_name: x ) right: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 17 length: 1 span_id: 14 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: 5 ) ] ) ) update: (arith_expr.UnaryAssign op_id: Id.Arith_DPlus child: (SimpleVarSub left: (Token id: Id.Lit_ArithVarLike col: 22 length: 1 span_id: 18 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: x ) var_name: x ) ) body: (command.DoGroup left: (Token id: Id.KW_Do col: 27 length: 2 span_id: 23 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: do ) children: [ (command.Sentence child: (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 30 length: 4 span_id: 25 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 30 length: 4 span_id: 25 line: (SourceLine line_num: 1 content: "for ((x = 1; x < 5; ++x)); do echo $x; done" src: (source.CFlag) ) tval: echo ) ] ) (CompoundWord parts: [ (SimpleVarSub left: (Token id: Id.VSub_DollarName col: 35 length: 2 span_id: 27 line: (SourceLine line_num: 1 content: "for ((x = 1; x < 5; ++x)); do echo $x; done" src: (source.CFlag) ) tval: "$x" ) var_name: x ) ] ) ] redirects: [] do_fork: T ) terminator: (Token id: Id.Op_Semi col: 37 length: 1 span_id: 28 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: _ ) ) ] right: (Token id: Id.KW_Done col: 39 length: 4 span_id: 30 line: (SourceLine line_num:1 content:"for ((x = 1; x < 5; ++x)); do echo $x; done" src:(source.CFlag)) tval: done ) ) redirects: [] ) ===== CASE: -n -c for ((x = 1; x < 5; ++x)); do echo $x; done ===== for ((x = 1; x < 5; ++x)); do echo $x; done ^~ [ -c flag ]:1: Bash for loops aren't allowed (parse_dparen) ===== CASE: -n -c if (1 > 0 and 43 > 42) { echo yes } ===== (command.If if_kw: arms: [ (IfArm keyword: cond: (condition.YshExpr e: (expr.Binary op: left: (expr.Compare left: (expr.Const c:) ops: [] comparators: [(expr.Const c:)] ) right: (expr.Compare left: (expr.Const c:) ops: [] comparators: [(expr.Const c:)] ) ) ) action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] spids: [0] ) ] else_action: [] redirects: [] ) ===== CASE: -n -c if ( (1 > 0 and 43 > 42) ) { echo yes } ===== (command.If if_kw: arms: [ (IfArm keyword: cond: (condition.YshExpr e: (expr.Binary op: left: (expr.Compare left: (expr.Const c:) ops: [] comparators: [(expr.Const c:)] ) right: (expr.Compare left: (expr.Const c:) ops: [] comparators: [(expr.Const c:)] ) ) ) action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] spids: [0] ) ] else_action: [] redirects: [] ) test/parse-errors.sh: line 908: ysh_to_make_nicer: command not found test/parse-errors.sh: line 909: ysh_nested_proc: command not found test/parse-errors.sh: line 910: ysh_var_decl: command not found test/parse-errors.sh: line 911: ysh_place_mutation: command not found test/parse-errors.sh: line 912: ysh_case: command not found test/parse-errors.sh: line 913: ysh_for: command not found test/parse-errors.sh: line 914: ysh_for_parse_bare_word: command not found test/parse-errors.sh: line 915: oils_issue_1118: command not found ===== CASE: -n -c for x in & ===== for x in & ^ [ -c flag ]:1: Invalid word in for loop ===== CASE: -n -c for (( i=0; i<10; i++ )) ls ===== for (( i=0; i<10; i++ )) ls ^~ [ -c flag ]:1: Invalid word after for expression ===== CASE: -n -c for ( i=0; i<10; i++ ) ===== for ( i=0; i<10; i++ ) ^ [ -c flag ]:1: Expected loop variable (a constant word) ===== CASE: -n -c for $x in 1 2 3; do echo $i; done ===== for $x in 1 2 3; do echo $i; done ^~ [ -c flag ]:1: Expected loop variable (a constant word) ===== CASE: -n -c for x.y in 1 2 3; do echo $i; done ===== for x.y in 1 2 3; do echo $i; done ^~~ [ -c flag ]:1: Invalid loop variable name 'x.y' ===== CASE: -n -c for x in 1 2 3; & ===== for x in 1 2 3; & ^ [ -c flag ]:1: Expected word type Id.KW_Do, got Id.Op_Amp ===== CASE: -n -c for foo BAD ===== for foo BAD ^ [ -c flag ]:1: Expected loop variable (a constant word) ===== CASE: -n -c for var in x; do echo $var; done ===== (command.ForEach keyword: (Token id: Id.KW_For col: 0 length: 3 span_id: 0 line: (SourceLine line_num:1 content:"for var in x; do echo $var; done" src:(source.CFlag)) tval: for ) iter_names: [var] iterable: (for_iter.Words words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 11 length: 1 span_id: 6 line: (SourceLine line_num:1 content:"for var in x; do echo $var; done" src:(source.CFlag)) tval: x ) ] ) ] ) semi_tok: (Token id: Id.Op_Semi col: 12 length: 1 span_id: 7 line: (SourceLine line_num:1 content:"for var in x; do echo $var; done" src:(source.CFlag)) tval: _ ) body: (command.DoGroup left: (Token id: Id.KW_Do col: 14 length: 2 span_id: 9 line: (SourceLine line_num:1 content:"for var in x; do echo $var; done" src:(source.CFlag)) tval: do ) children: [ (command.Sentence child: (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 17 length: 4 span_id: 11 line: (SourceLine line_num:1 content:"for var in x; do echo $var; done" src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 17 length: 4 span_id: 11 line: (SourceLine line_num:1 content:"for var in x; do echo $var; done" src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (SimpleVarSub left: (Token id: Id.VSub_DollarName col: 22 length: 4 span_id: 13 line: (SourceLine line_num:1 content:"for var in x; do echo $var; done" src:(source.CFlag)) tval: "$var" ) var_name: var ) ] ) ] redirects: [] do_fork: T ) terminator: (Token id: Id.Op_Semi col: 26 length: 1 span_id: 14 line: (SourceLine line_num:1 content:"for var in x; do echo $var; done" src:(source.CFlag)) tval: _ ) ) ] right: (Token id: Id.KW_Done col: 28 length: 4 span_id: 16 line: (SourceLine line_num:1 content:"for var in x; do echo $var; done" src:(source.CFlag)) tval: done ) ) redirects: [] ) test/parse-errors.sh: line 918: parse_at: command not found test/parse-errors.sh: line 788: _parse-error: command not found ===== CASE: -n -c write -- $f(x) ===== write -- $f(x) ^ [ -c flag ]:1: Space required before ( ===== CASE: -n -c write -- @[sorted(x)] ===== write -- @[sorted(x)] ^ [ -c flag ]:1: Unexpected left paren (might need a space before it) ===== CASE: -n -c write -- @[sorted(x)] ===== (command.Simple blame_tok: more_env: [] words: [ {} {<-->} { (word_part.ExprSub left: child: (expr.FuncCall func: (expr.Var name:) args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c f() { write -- @[sorted(x)] } ===== write -- @[sorted(x)] ^ [ -c flag ]:3: Unexpected left paren (might need a space before it) ===== CASE: -n -c f() { write -- @[sorted(x)] } ===== (command.ShFunction name_tok: name: f body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [ {} {<-->} { (word_part.ExprSub left: child: (expr.FuncCall func: (expr.Var name:) args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) ) right: ) } ] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c f() { write -- @sorted (( z )) } ===== write -- @sorted (( z )) ^~ [ -c flag ]:3: Invalid word while parsing command list ===== CASE: code="printf % x" eval $code ===== % ^ [ printf word at line 1 of [ eval word at line 3 of [ -c flag ] ] ]:1: Expected a printf format character ===== CASE: x="echo )" eval $x ===== echo ) ^ [ eval word at line 3 of [ -c flag ] ]:1: Invalid word while parsing command line ---------------------- ===== CASE: test/parse-errors/01-bad-func.sh ===== foo (,) ^ test/parse-errors/01-bad-func.sh:15: Syntax error in expression (near Id.Arith_Comma) ===== CASE: test/parse-errors/02-bad-func.sh ===== foo() ^ test/parse-errors/02-bad-func.sh:3: Unexpected word while parsing compound command ===== CASE: test/parse-errors/05-unterminated-single.sh ===== A B echo 'C ^ test/parse-errors/05-unterminated-single.sh:5: Unexpected EOF in single-quoted string that began here ===== CASE: test/parse-errors/06-unterminated-double-long.sh ===== A B echo 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 " ^ test/parse-errors/06-unterminated-double-long.sh:9: Unexpected EOF reading double-quoted string that began here ===== CASE: test/parse-errors/06-unterminated-double.sh ===== A B echo "0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 ^ test/parse-errors/06-unterminated-double.sh:6: Unexpected EOF reading double-quoted string that began here ===== CASE: test/parse-errors/07-unterminated-here-doc-2.sh ===== cat << "$@" ^ test/parse-errors/07-unterminated-here-doc-2.sh:2: Invalid here doc delimiter ===== CASE: test/parse-errors/07-unterminated-here-doc.sh ===== cat <