===== 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:) ===== 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 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 < arms: [ (IfArm keyword: cond: (condition.Shell commands: [ (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] do_fork: T ) ] ) then_kw: action: [] spids: [2 8] ) ] else_action: [] fi_kw: redirects: [] ) ===== CASE: -n -c while false do done ===== (command.WhileUntil keyword: cond: (condition.Shell commands: [ (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] do_fork: T ) ] ) body: (command.DoGroup left: children:[] right:) redirects: [] ) ===== CASE: -n -c while true; false do done ===== (command.WhileUntil keyword: cond: (condition.Shell commands: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] do_fork: T ) terminator: ) (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] do_fork: T ) ] ) body: (command.DoGroup left: children:[] right:) redirects: [] ) ===== CASE: -n -c if true then fi ===== (command.If if_kw: arms: [ (IfArm keyword: cond: (condition.Shell commands: [ (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] do_fork: T ) ] ) then_kw: action: [] spids: [2 7] ) ] else_action: [] fi_kw: redirects: [] ) ===== CASE: -n -c while true; false do done ===== (command.WhileUntil keyword: cond: (condition.Shell commands: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] do_fork: T ) terminator: ) (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] do_fork: T ) ] ) body: (command.DoGroup left: children:[] right:) redirects: [] ) ===== CASE: -n -c echo ${ ===== echo ${ ^ [ -c flag ]:1: Unexpected token in ${} ===== CASE: -n -c ${foo:} ===== ${foo:} ^ [ -c flag ]:1: Token can't be used in prefix position ===== CASE: -n -c echo ${a[@Z ===== echo ${a[@Z ^ [ -c flag ]:1: Expected ] to close subscript ===== CASE: -n -c echo ${x.} ===== echo ${x.} ^ [ -c flag ]:1: Expected } to close ${ ===== CASE: -n -c echo ${!x.} ===== echo ${!x.} ^ [ -c flag ]:1: Expected } to close ${ ===== CASE: -n -c echo ${a:1;} ===== echo ${a:1;} ^ [ -c flag ]:1: Expected : or } in slice ===== CASE: -n -c echo ${a:1:2;} ===== echo ${a:1:2;} ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Arith_Semi != Id.Arith_RBrace) ===== CASE: -n -c echo ${#a. ===== echo ${#a. ^ [ -c flag ]:1: Expected } after length expression ===== CASE: -n -c for (( i = 0; i < 10; i++ ; ===== for (( i = 0; i < 10; i++ ; ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Arith_Semi != Id.Arith_RParen) ===== CASE: -n -c for (( i = 0; i < 10; i++ / ===== for (( i = 0; i < 10; i++ / ^ [ -c flag ]:1: Unexpected end of input ===== CASE: -n -c echo @(extglob|foo ===== echo @(extglob|foo ^~ [ -c flag ]:1: Unexpected EOF reading extended glob that began here ===== CASE: -n -c ${undef:- ===== ${undef:- ^ [ -c flag ]:1: Expected } to close ${ ===== CASE: -n -c ${undef:-$ ===== ${undef:-$ ^ [ -c flag ]:1: Expected } to close ${ ===== CASE: -n -c ${undef:-$F ===== ${undef:-$F ^ [ -c flag ]:1: Expected } to close ${ ===== CASE: -n -c ${x@ ===== ${x@ ^ [ -c flag ]:1: Unexpected token in ${} (VOp3) ===== CASE: -n -c ${x@Q ===== ${x@Q ^ [ -c flag ]:1: Expected } to close ${ ===== CASE: -n -c ${x% ===== ${x% ^ [ -c flag ]:1: Expected } to close ${ ===== CASE: -n -c ${x/ ===== ${x/ ^ [ -c flag ]:1: Expected } after replacement string, got Id.Eof_Real ===== CASE: -n -c ${x/a/ ===== ${x/a/ ^ [ -c flag ]:1: Expected } after replacement string, got Id.Eof_Real ===== CASE: -n -c ${x/a/b ===== ${x/a/b ^ [ -c flag ]:1: Expected } after replacement string, got Id.Eof_Real ===== CASE: -n -c ${x: ===== ${x: ^ [ -c flag ]:1: Unexpected end of input ===== CASE: -n -c a=(1 & 2) ===== a=(1 & 2) ^ [ -c flag ]:1: Unexpected token in array literal ===== CASE: -n -c a= (1 2) ===== a= (1 2) ^ [ -c flag ]:1: Expected ( after = ===== CASE: -n -c a=(1 2 ===== a=(1 2 ^ [ -c flag ]:1: Unexpected token in array literal ===== CASE: -n -c a=(1 ${2@} ) ===== a=(1 ${2@} ) ^ [ -c flag ]:1: Unexpected token in ${} (VOp3) ===== CASE: -n -c echo ${x/} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: (rhs_word__Empty) replace_mode: Id.Undefined_Tok slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x//} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: (rhs_word__Empty) replace_mode: Id.Lit_Slash slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x/foo} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: (rhs_word__Empty) replace_mode: Id.Undefined_Tok slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x//foo} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: (rhs_word__Empty) replace_mode: Id.Lit_Slash slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x/%foo} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: (rhs_word__Empty) replace_mode: Id.Lit_Percent slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x///foo} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: { } replace: (rhs_word__Empty) replace_mode: Id.Lit_Slash slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x///} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: (rhs_word__Empty) replace_mode: Id.Lit_Slash slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x/%/} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: {} replace_mode: Id.Lit_Percent slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x////} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: {} replace_mode: Id.Lit_Slash slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x/%//} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: {} replace_mode: Id.Lit_Percent slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x//foo/replace } ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: {<'replace\n'>} replace_mode: Id.Lit_Slash slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo ${x//foo/replace$foo} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.PatSub pat: {} replace: { ($ Id.VSub_DollarName foo)} replace_mode: Id.Lit_Slash slash_tok: ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c "unterminated double ===== "unterminated double ^ [ -c flag ]:1: Unexpected EOF reading double-quoted string that began here ===== CASE: -n -c 'unterminated single ===== 'unterminated single ^ [ -c flag ]:1: Unexpected EOF in single-quoted string that began here ===== CASE: -n -c "unterminated double multiline line 1 line 2 ===== "unterminated double multiline ^ [ -c flag ]:2: Unexpected EOF reading double-quoted string that began here ===== CASE: -n -c 'unterminated single multiline line 1 line 2 ===== 'unterminated single multiline ^ [ -c flag ]:2: Unexpected EOF in single-quoted string that began here ===== CASE: -n -c echo ${x*} ===== echo ${x*} ^ [ -c flag ]:1: Unexpected token in ${} (VOp3) ===== CASE: -n -c echo ${x@} ===== echo ${x@} ^ [ -c flag ]:1: Unexpected token in ${} (VOp3) ===== CASE: -n -c echo ${x.} ===== echo ${x.} ^ [ -c flag ]:1: Expected } to close ${ ===== CASE: -n -c echo $(( 1 + 2 ; ===== echo $(( 1 + 2 ; ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Arith_Semi != Id.Arith_RParen) ===== CASE: -n -c echo $(( 1 + 2 ); ===== echo $(( 1 + 2 ); ^ [ -c flag ]:1: Expected second ) to end arith sub ===== CASE: -n -c echo $(( ===== echo $(( ^ [ -c flag ]:1: Unexpected end of input ===== CASE: -n -c echo $(( 1 ===== echo $(( 1 ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Eof_Real != Id.Arith_RParen) ===== CASE: -n -c (( 1 + 2 / ===== (( 1 + 2 / ^ [ -c flag ]:1: Unexpected end of input ===== CASE: -n -c (( 1 + 2 )/ ===== (( 1 + 2 )/ ^ [ -c flag ]:1: Expected second ) to end arith statement ===== CASE: -n -c (( 1 ===== (( 1 ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Eof_Real != Id.Arith_RParen) ===== CASE: -n -c (( ===== (( ^ [ -c flag ]:1: Unexpected end of input ===== CASE: -n -c a[x+]=1 ===== a[x+]=1 ^ [ array place in [ -c flag ] ]:1: Unexpected end of input ===== CASE: -n -c a[]=1 ===== a[]=1 ^ [ array place in [ -c flag ] ]:1: Unexpected end of input ===== CASE: -n -c a[*]=1 ===== a[*]=1 ^ [ array place in [ -c flag ] ]:1: Token can't be used in prefix position ===== CASE: -n -c (( a + { )) ===== (( a + { )) ^ [ -c flag ]:1: Unexpected token while parsing arithmetic: '{' ===== CASE: -n -c (( a + } )) ===== (( a + } )) ^ [ -c flag ]:1: Token can't be used in prefix position ===== CASE: -n -c echo $((a b)) ===== echo $((a b)) ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Word_Compound != Id.Arith_RParen) ===== CASE: -n -c ((a b)) ===== ((a b)) ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Word_Compound != Id.Arith_RParen) ===== CASE: -n -c for ((x=0; x<5; x++)); do echo $x; done ===== (command.ForExpr keyword: init: (arith_expr.BinaryAssign op_id: Id.Arith_Equal left: ($ Id.Lit_ArithVarLike x) right: {} ) cond: (arith_expr.Binary op_id: Id.Arith_Less left: ($ Id.Lit_ArithVarLike x) right: {} ) update: (arith_expr.UnaryAssign op_id:Id.Node_PostDPlus child:($ Id.Lit_ArithVarLike x)) body: (command.DoGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) terminator: ) ] right: ) redirects: [] ) ===== CASE: -n -c for ((; x<5; x++)); do echo $x; done ===== (command.ForExpr keyword: cond: (arith_expr.Binary op_id: Id.Arith_Less left: ($ Id.Lit_ArithVarLike x) right: {} ) update: (arith_expr.UnaryAssign op_id:Id.Node_PostDPlus child:($ Id.Lit_ArithVarLike x)) body: (command.DoGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) terminator: ) ] right: ) redirects: [] ) ===== CASE: -n -c for ((; ; x++)); do echo $x; done ===== (command.ForExpr keyword: update: (arith_expr.UnaryAssign op_id:Id.Node_PostDPlus child:($ Id.Lit_ArithVarLike x)) body: (command.DoGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) terminator: ) ] right: ) redirects: [] ) ===== CASE: -n -c for ((; ;)); do echo $x; done ===== (command.ForExpr keyword: body: (command.DoGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) terminator: ) ] right: ) redirects: [] ) ===== CASE: -n -c for ((x=0; x<5; x++ b)); do echo $x; done ===== for ((x=0; x<5; x++ b)); do echo $x; done ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Word_Compound != Id.Arith_RParen) ===== CASE: -n -c for ((x=0 b; x<5; x++)); do echo $x; done ===== for ((x=0 b; x<5; x++)); do echo $x; done ^ [ -c flag ]:1: Expected ; here ===== CASE: -n -c for ((x=0; x<5 b; x++)); do echo $x; done ===== for ((x=0; x<5 b; x++)); do echo $x; done ^ [ -c flag ]:1: Expected ; here ===== CASE: -n -c ${a:1+2 b} ===== ${a:1+2 b} ^ [ -c flag ]:1: Expected : or } in slice ===== CASE: -n -c ${a:1+2:3+4 b} ===== ${a:1+2:3+4 b} ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Word_Compound != Id.Arith_RBrace) ===== CASE: -n -c ${a[1+2 b]} ===== ${a[1+2 b]} ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Word_Compound != Id.Arith_RBracket) ===== CASE: -n -c $(( 1 + + )) ===== $(( 1 + + )) ^ [ -c flag ]:1: Token can't be used in prefix position ===== CASE: -n -c $(( 1 2 )) ===== $(( 1 2 )) ^ [ -c flag ]:1: Unexpected token after arithmetic expression (Id.Word_Compound != Id.Arith_RParen) ===== CASE: -n -c $(( - ; )) ===== $(( - ; )) ^ [ -c flag ]:1: Token can't be used in prefix position ===== CASE: -n -c $(( ` )) ===== $(( ` )) ^ [ -c flag ]:1: Unexpected EOF while looking for closing backtick ===== CASE: -n -c $(( $ )) ===== $(( $ )) ^ [ -c flag ]:1: Unexpected token while parsing arithmetic: '$' ===== CASE: -n -c $(( x+1 = 42 )) ===== $(( x+1 = 42 )) ^ [ -c flag ]:1: Left-hand side of this assignment is invalid ===== CASE: -n -c $(( (x+42)++ )) ===== $(( (x+42)++ )) ^~ [ -c flag ]:1: Left-hand side of this assignment is invalid ===== CASE: -n -c $(( ++(x+42) )) ===== $(( ++(x+42) )) ^~ [ -c flag ]:1: Left-hand side of this assignment is invalid ===== CASE: -n -c [[ a b ]] ===== [[ a b ]] ^ [ -c flag ]:1: Expected ]] ===== CASE: -n -c [[ a "a"$(echo hi)"b" ]] ===== [[ a "a"$(echo hi)"b" ]] ^ [ -c flag ]:1: Expected ]] ===== CASE: -n -c [[ a == ]] ===== [[ a == ]] ^ [ -c flag ]:1: Expected ]] ===== CASE: -n -c [[ ( 1 == 2 - ]] ===== [[ ( 1 == 2 - ]] ^ [ -c flag ]:1: Expected ), got word.Compound ===== CASE: -n -c [[ == ]] ===== [[ == ]] ^~ [ -c flag ]:1: Unexpected token in boolean expression (Id.BoolBinary_GlobDEqual) ===== CASE: -n -c [[ ) ]] ===== [[ ) ]] ^ [ -c flag ]:1: Unexpected token in boolean expression (Id.Op_RParen) ===== CASE: -n -c [[ ( ]] ===== [[ ( ]] ^~ [ -c flag ]:1: Unexpected token in boolean expression (Id.Lit_DRightBracket) ===== CASE: -n -c [[ ;;; ]] ===== [[ ;;; ]] ^~ [ -c flag ]:1: Unexpected token in boolean expression (Id.Op_DSemi) ===== CASE: -n -c [[ ===== [[ ^ [ -c flag ]:1: Unexpected token in boolean expression (Id.Eof_Real) ===== CASE: -n -c [[ ( a == b foo${var} ]] ===== [[ ( a == b foo${var} ]] ^~~ [ -c flag ]:1: Expected ), got word.Compound ===== CASE: [ x -a y f ] ===== [ x -a y f ] ^ [ -c flag ]:1: (test) Unexpected trailing word 'f' ===== CASE: test x -a y f ===== test x -a y f ^ [ -c flag ]:1: (test) Unexpected trailing word 'f' ===== CASE: [ x ===== [ x ^ [ -c flag ]:1: missing closing ] ===== CASE: [ x x ] ===== [ x x ] ^ [ -c flag ]:1: (test) Expected unary operator, got 'x' (2 args) ===== CASE: [ x x "a b" ] ===== [ x x "a b" ] ^ [ -c flag ]:1: (test) Expected binary operator, got 'x' (3 args) ===== CASE: [ -t xxx ] ===== [ -t xxx ] ^~~ [ -c flag ]:1: (test) Invalid file descriptor 'xxx' ===== CASE: [ \( x -a -y -a z ] ===== [??? no location ???] (test) Expected ), got EOF ===== CASE: printf % ===== % ^ [ printf word at line 1 of [ -c flag ] ]:1: Expected a printf format character ===== CASE: printf [%Z] ===== [%Z] ^ [ printf word at line 1 of [ -c flag ] ]:1: Invalid printf format character ===== CASE: printf -v "-invalid-" %s foo ===== -invalid- ^ [ dynamic place word at ? ]:1: Unexpected end of input printf -v "-invalid-" %s foo ^~~~~~ [ -c flag ]:1: 'printf' got invalid place expression ===== CASE: shift 1 2 ===== shift 1 2 ^~~~~ [ -c flag ]:1: 'shift' got too many arguments ===== CASE: shift zzz ===== shift zzz ^~~~~ [ -c flag ]:1: 'shift' Invalid shift argument 'zzz' ===== CASE: pushd x y ===== pushd x y ^ [ -c flag ]:1: 'pushd' got too many arguments ===== CASE: pwd -x ===== pwd -x ^~ [ -c flag ]:1: 'pwd' doesn't accept flag -x ===== CASE: pp x foo a-x ===== pp x foo a-x ^ [ -c flag ]:1: 'pp' got invalid action 'x' ===== CASE: wait zzz ===== wait zzz ^~~ [ -c flag ]:1: 'wait' expected PID or jobspec, got 'zzz' ===== CASE: wait %jobspec-not-supported ===== wait %jobspec-not-supported ^ [ -c flag ]:1: 'wait' expected PID or jobspec, got '%jobspec-not-supported' ===== CASE: unset invalid-var-name ===== unset invalid-var-name ^~~~~ [ -c flag ]:1: fatal: Invalid place to modify ===== CASE: getopts hc: invalid-var-name ===== getopts hc: invalid-var-name ^~ [ -c flag ]:1: 'getopts' got invalid variable name 'invalid-var-name' ===== CASE: read -x ===== read -x ^~ [ -c flag ]:1: 'read' doesn't accept flag -x ===== CASE: builtin read -x ===== builtin read -x ^~ [ -c flag ]:1: 'read' doesn't accept flag -x ===== CASE: read -n ===== read -n ^~ [ -c flag ]:1: 'read' expected argument to '-n' ===== CASE: read -n x ===== read -n x ^ [ -c flag ]:1: 'read' expected integer after -n, got 'x' ===== CASE: set -o errexit +o oops ===== set -o errexit +o oops ^~~ [ -c flag ]:1: 'set' got invalid option 'oops' osh usage error: got invalid argument 'x' to '-ast-format', expected one of: text|abbrev-text|html|abbrev-html|oheap|none oils: got invalid option 'oops' ===== CASE: -n -c echo {1..3..-1} ===== echo {1..3..-1} ^~~~~~~~ [ -c flag ]:1: Invalid step -1 for ascending integer range ===== CASE: -n -c echo {1..3..0} ===== echo {1..3..0} ^~~~~~~ [ -c flag ]:1: Step can't be 0 ===== CASE: -n -c echo {3..1..1} ===== echo {3..1..1} ^~~~~~~ [ -c flag ]:1: Invalid step 1 for descending integer range ===== CASE: -n -c echo {3..1..0} ===== echo {3..1..0} ^~~~~~~ [ -c flag ]:1: Step can't be 0 ===== CASE: -n -c echo {a..Z} ===== echo {a..Z} ^~~~ [ -c flag ]:1: Mismatched cases in character range ===== CASE: -n -c echo {a..z..0} ===== echo {a..z..0} ^~~~~~~ [ -c flag ]:1: Step can't be 0 ===== CASE: -n -c echo {a..z..-1} ===== echo {a..z..-1} ^~~~~~~~ [ -c flag ]:1: Invalid step -1 for ascending character range ===== CASE: -n -c echo {z..a..1} ===== echo {z..a..1} ^~~~~~~ [ -c flag ]:1: Invalid step 1 for descending character range ===== CASE: append ===== append ^~~~~~ [ -c flag ]:1: 'append' requires a variable name ===== CASE: append invalid- ===== append invalid- ^~~~~~~~ [ -c flag ]:1: 'append' got invalid variable name 'invalid-' test/parse-errors.sh: line 1490: blocks: command not found test/parse-errors.sh: line 1491: parse_brace: command not found test/parse-errors.sh: line 1492: regex_literals: command not found test/parse-errors.sh: line 1493: proc_sig: command not found ===== CASE: -n -c json write (x) ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c echo $(json write (x)) ===== (command.Simple blame_tok: more_env: [] words: [ {} { (CommandSub left_token: child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) do_fork: T ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c var result = $(json write (x)) ===== (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (CommandSub left_token: child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) do_fork: T ) right: ) ) ===== CASE: -n -c json write (x, y); echo hi ===== (command.CommandList children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:) (expr.Var name:)] named_args: [] right: ) do_fork: T ) terminator: ) (command.Simple blame_tok: more_env:[] words:[{} {}] redirects:[] do_fork:T) ] ) ===== CASE: -n -c json write (x, name = "value") echo hi ===== (command.CommandList children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [(NamedArg name: value:(DQ ))] right: ) do_fork: T ) (command.Simple blame_tok: more_env:[] words:[{} {}] redirects:[] do_fork:T) ] ) ===== CASE: -n -c json write (x) { echo hi } ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) block: (BlockArg brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [(SourceLine line_num:1 content:'json write (x) { echo hi }' src:(source__CFlag))] ) do_fork: T ) ===== CASE: -n -c json write (x) { echo hi } ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) block: (BlockArg brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [ (SourceLine line_num:2 content:'json write (x) {\n' src:(source__CFlag)) (SourceLine line_num:3 content:' echo hi\n' src:(source__CFlag)) (SourceLine line_num:4 content:'}' src:(source__CFlag)) ] ) do_fork: T ) ===== CASE: -n -c json write ( x, y, z ) ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [ (expr.Var name:) (expr.Var name:) (expr.Var name:) ] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c json write () ===== json write () ^ [ -c flag ]:1: Empty arg list not allowed ===== CASE: -n -c json write ( ) ===== json write ( ) ^ [ -c flag ]:1: Empty arg list not allowed ===== CASE: -n -c json write(x) ===== json write(x) ^ [ -c flag ]:1: Space required before ( ===== CASE: -n -c json write() ===== json write() ^ [ -c flag ]:1: Space required before ( ===== CASE: -n -c f(x) ===== f(x) ^ [ -c flag ]:1: Space required before ( test/parse-errors.sh: line 1495: ysh_var: command not found test/parse-errors.sh: line 1496: ysh_expr_more: command not found test/parse-errors.sh: line 1497: ysh_hay_assign: command not found ===== CASE: -n -c echo $'\u{03bc' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [ ] right: ) } ] redirects: [] do_fork: T ) ===== CASE: +O parse_backslash -n -c echo parse_backslash $'\u{03bc' ===== echo parse_backslash $'\u{03bc' ^ [ -c flag ]:1: Invalid char escape in C-style string literal ===== CASE: -n -c const bad = $'\u{03bc' ===== const bad = $'\u{03bc' ^ [ -c flag ]:1: Invalid char escape in C-style string literal ===== CASE: -n -c echo $'\z' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [ ] right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c const bad = $'\z' ===== const bad = $'\z' ^ [ -c flag ]:1: Invalid char escape in C-style string literal ===== CASE: -n -c echo $'\101' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [] right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c const bad = $'\101' ===== const bad = $'\101' ^~~~ [ -c flag ]:1: Use \xhh or \u{...} instead of octal escapes in YSH strings ===== CASE: -n -c const bad = c'\xf' ===== const bad = c'\xf' ^ [ -c flag ]:1: Syntax error in expression (near Id.Left_SingleQuote) ===== CASE: -n -c echo "\z" ===== (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ===== CASE: +O parse_backslash -n -c echo parse_backslash "\z" ===== echo parse_backslash "\z" ^ [ -c flag ]:1: Invalid char escape in double quoted string ===== CASE: -n -c echo "\z" ===== echo "\z" ^ [ -c flag ]:1: Invalid char escape in double quoted string ===== CASE: -n -c const bad = "\z" ===== const bad = "\z" ^ [ -c flag ]:1: Invalid char escape in double quoted string ===== CASE: -n -c echo "\u1234" ===== (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ===== CASE: -n -c echo "\u1234" ===== echo "\u1234" ^ [ -c flag ]:1: Invalid char escape in double quoted string ===== CASE: -n -c const bad = "\u1234" ===== const bad = "\u1234" ^ [ -c flag ]:1: Invalid char escape in double quoted string ===== CASE: -n -c echo "`echo hi`" ===== (command.Simple blame_tok: more_env: [] words: [ {} { (DQ (CommandSub left_token: child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) right: ) ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo "`echo hi`" ===== echo "`echo hi`" ^ [ -c flag ]:1: Use $(cmd) instead of backticks (parse_backticks) ===== CASE: -n -c const bad = "`echo hi`" ===== const bad = "`echo hi`" ^ [ -c flag ]:1: Invalid backtick: use $(cmd) or \` in YSH strings ===== CASE: -n -c setvar x = "\z" ===== setvar x = "\z" ^ [ -c flag ]:1: Invalid char escape in double quoted string ===== CASE: -n -c setvar x = $'\z' ===== setvar x = $'\z' ^ [ -c flag ]:1: Invalid char escape in C-style string literal ===== CASE: -n -c echo `echo hi` ===== (command.Simple blame_tok: more_env: [] words: [ {} { (CommandSub left_token: child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo "foo = `echo hi`" ===== (command.Simple blame_tok: more_env: [] words: [ {} { (DQ <'foo = '> (CommandSub left_token: child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) right: ) ) } ] redirects: [] do_fork: T ) ===== CASE: +O parse_backticks -n -c echo `echo hi` ===== echo `echo hi` ^ [ -c flag ]:1: Use $(cmd) instead of backticks (parse_backticks) ===== CASE: +O parse_backticks -n -c echo "foo = `echo hi`" ===== echo "foo = `echo hi`" ^ [ -c flag ]:1: Use $(cmd) instead of backticks (parse_backticks) ===== CASE: -n -c echo $ ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ===== CASE: +O parse_dollar -n -c echo $ ===== echo $ ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo $ ===== echo $ ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo $: ===== (command.Simple blame_tok: more_env: [] words: [{} { }] redirects: [] do_fork: T ) ===== CASE: +O parse_dollar -n -c echo $: ===== echo $: ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo $: ===== echo $: ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo "$" ===== (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ===== CASE: +O parse_dollar -n -c echo "$" ===== echo "$" ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo "$" ===== echo "$" ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo "$:" ===== (command.Simple blame_tok: more_env: [] words: [{} {(DQ <':'>)}] redirects: [] do_fork: T ) ===== CASE: +O parse_dollar -n -c echo "$:" ===== echo "$:" ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo "$:" ===== echo "$:" ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo ${x:-$} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.Unary op: arg_word:{}) right: ) } ] redirects: [] do_fork: T ) ===== CASE: +O parse_dollar -n -c echo ${x:-$} ===== echo ${x:-$} ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo ${x:-$} ===== echo ${x:-$} ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo ${x:-$:} ===== (command.Simple blame_tok: more_env: [] words: [ {} { (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.Unary op: arg_word:{ <':'>}) right: ) } ] redirects: [] do_fork: T ) ===== CASE: +O parse_dollar -n -c echo ${x:-$:} ===== echo ${x:-$:} ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo ${x:-$:} ===== echo ${x:-$:} ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo "${x:-$}" ===== (command.Simple blame_tok: more_env: [] words: [ {} { (DQ (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.Unary op: arg_word:{}) right: ) ) } ] redirects: [] do_fork: T ) ===== CASE: +O parse_dollar -n -c echo "${x:-$}" ===== echo "${x:-$}" ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo "${x:-$}" ===== echo "${x:-$}" ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo "${x:-$:}" ===== (command.Simple blame_tok: more_env: [] words: [ {} { (DQ (BracedVarSub left: token: var_name: x suffix_op: (suffix_op.Unary op: arg_word:{ <':'>}) right: ) ) } ] redirects: [] do_fork: T ) ===== CASE: +O parse_dollar -n -c echo "${x:-$:}" ===== echo "${x:-$:}" ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo "${x:-$:}" ===== echo "${x:-$:}" ^ [ -c flag ]:1: Literal $ should be quoted like \$ ===== CASE: -n -c echo \( ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:'(')}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \; ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:';')}] redirects: [] do_fork: T ) ===== CASE: -n -c echo ~ ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.TildeSub token:)}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \! ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:'!')}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \% ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:'%')}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \# ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:'#')}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \. ===== echo \. ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \- ===== echo \- ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \/ ===== echo \/ ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \a ===== echo \a ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \Z ===== echo \Z ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \0 ===== echo \0 ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \9 ===== echo \9 ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \. \- \/ \a \Z \0 \9 ===== (command.Simple blame_tok: more_env: [] words: [ {} {(word_part.EscapedLiteral token: ch:.)} {(word_part.EscapedLiteral token: ch:-)} {(word_part.EscapedLiteral token: ch:'/')} {(word_part.EscapedLiteral token: ch:a)} {(word_part.EscapedLiteral token: ch:Z)} {(word_part.EscapedLiteral token: ch:0)} {(word_part.EscapedLiteral token: ch:9)} ] redirects: [] do_fork: T ) ===== CASE: -n -c ((1 > 0 && 43 > 42)) ===== (command.DParen left: child: (arith_expr.Binary op_id: Id.Arith_DAmp left: (arith_expr.Binary op_id:Id.Arith_Great left:{} right:{}) right: (arith_expr.Binary op_id: Id.Arith_Great left: {} right: {} ) ) right: 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: arms: [ (IfArm keyword: cond: (condition.Shell commands: [ (command.Sentence child: (command.DParen left: child: (arith_expr.Binary op_id: Id.Arith_DAmp left: (arith_expr.Binary op_id: Id.Arith_Great left: {} right: {} ) right: (arith_expr.Binary op_id: Id.Arith_Great left: {} right: {} ) ) right: redirects: [] ) terminator: ) ] ) then_kw: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] spids: [0 20] ) ] else_action: [] fi_kw: 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: init: (arith_expr.BinaryAssign op_id: Id.Arith_Equal left: ($ Id.Lit_ArithVarLike x) right: {} ) cond: (arith_expr.Binary op_id: Id.Arith_Less left: ($ Id.Lit_ArithVarLike x) right: {} ) update: (arith_expr.UnaryAssign op_id:Id.Arith_DPlus child:($ Id.Lit_ArithVarLike x)) body: (command.DoGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) terminator: ) ] right: ) 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: [] ) ===== CASE: -n -c = ===== = ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c _ ===== _ ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c const d = { name: 42 } ===== const d = { name: ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_Newline) test/parse-errors.sh: line 1504: ysh_nested_proc: command not found ===== CASE: -n -c proc p(x) { echo hi var x = 2 # Cannot redeclare param } ===== var x = 2 # Cannot redeclare param ^ [ -c flag ]:4: 'x' was already declared ===== CASE: -n -c proc p { var x = 1 echo hi var x = 2 # Cannot redeclare local } ===== var x = 2 # Cannot redeclare local ^ [ -c flag ]:5: 'x' was already declared ===== CASE: -n -c proc p { var x = 1 echo hi const x = 2 # Cannot redeclare local } ===== const x = 2 # Cannot redeclare local ^ [ -c flag ]:5: 'x' was already declared ===== CASE: -n -c proc p(x, :out) { var out = 2 # Cannot redeclare out param } ===== proc p(x, :out) { ^ [ -c flag ]:2: Syntax error in expression (near Id.Arith_Colon) ===== CASE: -n -c proc p { var out = 2 # Cannot redeclare out param cd /tmp { var out = 3 } } ===== var out = 3 ^~~ [ -c flag ]:5: 'out' was already declared ===== CASE: -n -c var x = 1 proc p { echo hi var x = 2 } proc p2 { var x = 3 } ===== (command.CommandList children: [ (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) (command.Proc keyword: name:

sig: (proc_sig__Open) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) ] redirects: [] right: ) ) (command.Proc keyword: name: sig: (proc_sig__Open) body: (BraceGroup left: children: [ (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) ] redirects: [] right: ) ) ] ) ===== CASE: -n -c proc p(x) { var y = 1 setvar L = "L" # ERROR: not declared } ===== setvar L = "L" # ERROR: not declared ^ [ -c flag ]:4: 'L' hasn't been declared ===== CASE: -n -c proc p(x) { const c = 123 setvar c = 42 # ERROR: cannot modify constant } ===== setvar c = 42 # ERROR: cannot modify constant ^ [ -c flag ]:4: Can't modify constant 'c' ===== CASE: -n -c proc p(x) { setvar x = "X" # is mutating params allowed? I guess why not. } ===== (command.Proc keyword: name:

sig: (proc_sig.Closed word_params: [(Param blame_tok: name:x)] pos_params: [] named_params: [] ) body: (BraceGroup left: children: [ (command.PlaceMutation keyword: lhs: [(place_expr.Var name:)] op: rhs: (DQ ) ) ] redirects: [] right: ) ) ===== CASE: -n -c case (x) { (else) { = 1; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Sentence child: (command.Expr keyword: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { (else) { echo 1 } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {<1>}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { (else) { = 1 } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [(command.Expr keyword: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { (else) { = 1 } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [(command.Expr keyword: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { (else) { = 1 } # Comment } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [(command.Expr keyword: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (3) { (3) { echo hi } # comment line } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Const c:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { (else) { echo 1 } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {<1>}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { (else) { echo } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [(command.Simple blame_tok: more_env:[] words:[{}] redirects:[] do_fork:T)] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { *.py { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{ <.py>}]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { (obj.attr) { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (Attribute obj: (expr.Var name:) op: attr: ctx: expr_context.Store ) ] ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { (0) { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (add(10, 32)) { (40 + 2) { echo Found the answer } (else) { echo Incorrect } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e: (expr.FuncCall func: (expr.Var name:) args: (ArgList left: pos_args: [(expr.Const c:) (expr.Const c:)] named_args: [] right: ) ) ) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (expr.Binary op: left: (expr.Const c:) right: (expr.Const c:) ) ] ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {} {} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (file) { / dot* '.py' / { echo Python } / dot* ('.cc' | '.h') / { echo C++ } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Eggex eggex: (re.Seq children: [ (re.Repeat child: op: (re_repeat.Op op:) ) (SQ <.py>) ] ) ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (pat.Eggex eggex: (re.Seq children: [ (re.Repeat child: op: (re_repeat.Op op:) ) (re.Group child:(re.Alt children:[(SQ <.cc>) (SQ <.h>)])) ] ) ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} { }] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (lang) { en-US | en-CA | en-UK { echo Hello } fr-FR | fr-CA { echo Bonjour } (else) { echo o/ } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{} {} {}]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (pat.Words words:[{} {}]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {<'o/'>}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (num) { (1) | (2) { echo number } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [(expr.Const c:) (expr.Const c:)] ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (num) { (1) | (2) | (3) | (4) | (5) { echo small } (else) { echo large } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (expr.Const c:) (expr.Const c:) (expr.Const c:) (expr.Const c:) (expr.Const c:) ] ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (add(10, 32)) { (40 + 2) { echo Found the answer } (else) { echo Incorrect } } ===== case ^ [ -c flag ]:2: Expected a word to match against ===== CASE: -n -c case (file) { ('README') | / dot* '.md' / { echo Markdown } } ===== case (file) ^ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.Op_Newline ===== CASE: -n -c case (file) { { echo Python } } ===== case (file) ^ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.Op_Newline ===== CASE: -n -c case (file) { cc h { echo C++ } } ===== case (file) ^ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.Op_Newline ===== CASE: -n -c case (lang) { en-US | ('en-CA') | / 'en-UK' / { echo Hello } } ===== | ('en-CA') ^ [ -c flag ]:4: Expected case pattern ===== CASE: -n -c case (lang) { else) { echo o/ } } ===== else) { ^ [ -c flag ]:3: Expected word type Id.Lit_LBrace, got Id.Op_RParen ===== CASE: -n -c case (num) { (1) | (2) | (3) | (4) | (5) { echo small } (6) | (else) { echo large } } ===== (6) | (else) { ^~~~ [ -c flag ]:8: Syntax error in expression (near Id.Expr_Else) ===== CASE: -n -c case $foo { ("main.py") { echo "python" } } ===== case $foo { ^ [ -c flag ]:2: Expected word type Id.KW_In, got Id.Lit_LBrace ===== CASE: -n -c case (x) { *.py { echo "python" } } ===== case (x) ^ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.Op_Newline ===== CASE: -n -c case (foo) in *.py { echo "python" } esac ===== case (foo) in ^~ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.KW_In ===== CASE: -n -c case $foo { bar) { echo "python" } } ===== case $foo { ^ [ -c flag ]:2: Expected word type Id.KW_In, got Id.Lit_LBrace ===== CASE: -n -c case (x) { { echo "python" } } ===== echo "python" ^~~~ [ -c flag ]:4: Expected word type Id.Lit_LBrace, got Id.Word_Compound ===== CASE: -n -c case (x { *.py { echo "python" } } ===== case (x { ^ [ -c flag ]:2: Syntax error in expression (near Id.Op_LBrace) ===== CASE: -n -c case (x) { *.py) { echo "python" } } ===== *.py) { echo "python" } ^ [ -c flag ]:3: Expected word type Id.Lit_LBrace, got Id.Op_RParen ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.Eggex eggex:(SQ )) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.Eggex eggex:(SQ )) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.Eggex eggex:(SQ )) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.Eggex eggex:(SQ )) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.Eggex eggex:(SQ )) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.Eggex eggex:(SQ )) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c for x in (obj) { echo $x } ===== (command.ForEach keyword: iter_names: [x] iterable: (for_iter.YshExpr e:(expr.Var name:) blame:) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) ===== CASE: -n -c for x in (obj); do echo $x done ===== for x in (obj); do ^ [ -c flag ]:2: Expected { after iterable expression ===== CASE: -n -c for x, y in SPAM EGGS; do echo $x done ===== (command.ForEach keyword: iter_names: [x y] iterable: (for_iter.Words words:[{} {}]) semi_tok: body: (command.DoGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] right: ) redirects: [] ) ===== CASE: -n -c for x-y in SPAM EGGS; do echo $x done ===== for x-y in SPAM EGGS; do ^~~ [ -c flag ]:2: Invalid loop variable name 'x-y' ===== CASE: -n -c for x, y, z in SPAM EGGS; do echo $x done ===== for x, y, z in SPAM EGGS; do ^~~ [ -c flag ]:2: Expected at most 2 loop variables ===== CASE: -n -c for w, x, y, z in SPAM EGGS; do echo $x done ===== for w, x, y, z in SPAM EGGS; do ^ [ -c flag ]:2: Unexpected word after 3 loop variables ===== CASE: -n -c for x, y in SPAM EGGS do echo $x done ===== (command.ForEach keyword: iter_names: [x y] iterable: (for_iter.Words words:[{} {}]) body: (command.DoGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] right: ) redirects: [] ) ===== CASE: -n -c for const in (x) { echo $var } ===== (command.ForEach keyword: iter_names: [const] iterable: (for_iter.YshExpr e:(expr.Var name:) blame:) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName var)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) ===== CASE: -n -c for x in bare { echo $x } ===== for x in bare { ^~~~ [ -c flag ]:2: Surround this word with either parens or quotes (parse_bare_word) ===== CASE: -n -c for x in a b { echo $x } ===== (command.ForEach keyword: iter_names: [x] iterable: (for_iter.Words words:[{} {}]) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) ===== CASE: -n -c for x in *.py { echo $x } ===== (command.ForEach keyword: iter_names: [x] iterable: (for_iter.Words words:[{ <.py>}]) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) ===== CASE: -n -c for x in "quoted" { echo $x } ===== (command.ForEach keyword: iter_names: [x] iterable: (for_iter.Words words:[{(DQ )}]) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) ===== CASE: -n -c var snippets = [{status: 42}] for snippet in (snippets) { if (snippet["status"] === 0) { echo hi } # The $ causes a weird error if ($snippet["status"] === 0) { echo hi } } ===== if ($snippet["status"] === 0) { ^~~~~~~~ [ -c flag ]:9: In expressions, remove $ and use `snippet`, or sometimes "$snippet" ===== CASE: -n -c var content = [ 1, 2, 4 ] var count = 0 # The $ causes a weird error while (count < $len(content)) { setvar count += 1 } ===== while (count < $len(content)) { ^~~~ [ -c flag ]:6: In expressions, remove $ and use `len`, or sometimes "$len" ===== 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: iter_names: [var] iterable: (for_iter.Words words:[{}]) semi_tok: body: (command.DoGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName var)}] redirects: [] do_fork: T ) terminator: ) ] right: ) redirects: [] ) test/parse-errors.sh: line 1513: parse_at: command not found test/parse-errors.sh: line 867: _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 <