===== 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 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 < 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'json write (\n' src:(source.CFlag)) tval: json ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'json write (\n' src:(source.CFlag)) tval: json ) ] ) (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 5 length: 5 span_id: 2 line: (SourceLine line_num:1 content:'json write (\n' src:(source.CFlag)) tval: write ) ] ) ] redirects: [] typed_args: (ArgList left: (Token id: Id.Op_LParen col: 11 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'json write (\n' src:(source.CFlag)) tval: _ ) pos_args: [ (expr.Var name: (Token id: Id.Expr_Name col: 4 length: 1 span_id: 7 line: (SourceLine line_num:2 content:' x,\n' src:(source.CFlag)) tval: x ) ) (expr.Var name: (Token id: Id.Expr_Name col: 4 length: 1 span_id: 11 line: (SourceLine line_num:3 content:' y,\n' src:(source.CFlag)) tval: y ) ) (expr.Var name: (Token id: Id.Expr_Name col: 4 length: 1 span_id: 15 line: (SourceLine line_num:4 content:' z\n' src:(source.CFlag)) tval: z ) ) ] named_args: [] right: (Token id: Id.Op_RParen col: 2 length: 1 span_id: 18 line: (SourceLine line_num:5 content:' )' src:(source.CFlag)) tval: _ ) ) 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $\'\\u{03bc\'' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $\'\\u{03bc\'' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (SingleQuoted left: (Token id: Id.Left_DollarSingleQuote col: 5 length: 2 span_id: 2 line: (SourceLine line_num:1 content:'echo $\'\\u{03bc\'' src:(source.CFlag)) tval: '$\'' ) tokens: [ (Token id: Id.Unknown_Backslash col: 7 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo $\'\\u{03bc\'' src:(source.CFlag)) tval: '\\' ) (Token id: Id.Char_Literals col: 8 length: 6 span_id: 4 line: (SourceLine line_num:1 content:'echo $\'\\u{03bc\'' src:(source.CFlag)) tval: 'u{03bc' ) ] right: (Token id: Id.Right_SingleQuote col: 14 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo $\'\\u{03bc\'' src:(source.CFlag)) tval: '\'' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $\'\\z\'' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $\'\\z\'' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (SingleQuoted left: (Token id: Id.Left_DollarSingleQuote col: 5 length: 2 span_id: 2 line: (SourceLine line_num:1 content:'echo $\'\\z\'' src:(source.CFlag)) tval: '$\'' ) tokens: [ (Token id: Id.Unknown_Backslash col: 7 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo $\'\\z\'' src:(source.CFlag)) tval: '\\' ) (Token id: Id.Char_Literals col: 8 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo $\'\\z\'' src:(source.CFlag)) tval: z ) ] right: (Token id: Id.Right_SingleQuote col: 9 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo $\'\\z\'' src:(source.CFlag)) tval: '\'' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $\'\\101\'' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $\'\\101\'' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (SingleQuoted left: (Token id: Id.Left_DollarSingleQuote col: 5 length: 2 span_id: 2 line: (SourceLine line_num:1 content:'echo $\'\\101\'' src:(source.CFlag)) tval: '$\'' ) tokens: [ (Token id: Id.Char_Octal3 col: 7 length: 4 span_id: 3 line: (SourceLine line_num:1 content:'echo $\'\\101\'' src:(source.CFlag)) tval: '\\101' ) ] right: (Token id: Id.Right_SingleQuote col: 11 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo $\'\\101\'' src:(source.CFlag)) tval: '\'' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "\\z"' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "\\z"' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (DoubleQuoted left: (Token id: Id.Left_DoubleQuote col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo "\\z"' src:(source.CFlag)) tval: '"' ) parts: [ (Token id: Id.Lit_BadBackslash col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo "\\z"' src:(source.CFlag)) tval: '\\' ) (Token id: Id.Lit_Chars col: 7 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo "\\z"' src:(source.CFlag)) tval: z ) ] right: (Token id: Id.Right_DoubleQuote col: 8 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo "\\z"' src:(source.CFlag)) tval: '"' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "\\u1234"' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "\\u1234"' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (DoubleQuoted left: (Token id: Id.Left_DoubleQuote col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo "\\u1234"' src:(source.CFlag)) tval: '"' ) parts: [ (Token id: Id.Lit_BadBackslash col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo "\\u1234"' src:(source.CFlag)) tval: '\\' ) (Token id: Id.Lit_Chars col: 7 length: 5 span_id: 4 line: (SourceLine line_num:1 content:'echo "\\u1234"' src:(source.CFlag)) tval: u1234 ) ] right: (Token id: Id.Right_DoubleQuote col: 12 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo "\\u1234"' src:(source.CFlag)) tval: '"' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (DoubleQuoted left: (Token id: Id.Left_DoubleQuote col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '"' ) parts: [ (CommandSub left_token: (Token id: Id.Left_Backtick col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '`' ) child: (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 6 line: (SourceLine line_num: 1 content: 'echo hi' src: (source.Reparsed what: backticks left_token: (Token id: Id.Left_Backtick col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '`' ) right_token: (Token id: Id.Backtick_Right col: 14 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '`' ) ) ) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 6 line: (SourceLine line_num: 1 content: 'echo hi' src: (source.Reparsed what: backticks left_token: (Token id: Id.Left_Backtick col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '`' ) right_token: (Token id: Id.Backtick_Right col: 14 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '`' ) ) ) tval: echo ) ] ) (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 5 length: 2 span_id: 8 line: (SourceLine line_num: 1 content: 'echo hi' src: (source.Reparsed what: backticks left_token: (Token id: Id.Left_Backtick col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '`' ) right_token: (Token id: Id.Backtick_Right col: 14 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '`' ) ) ) tval: hi ) ] ) ] redirects: [] do_fork: T ) right: (Token id: Id.Backtick_Right col: 14 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '`' ) ) ] right: (Token id: Id.Right_DoubleQuote col: 15 length: 1 span_id: 10 line: (SourceLine line_num:1 content:'echo "`echo hi`"' src:(source.CFlag)) tval: '"' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (CommandSub left_token: (Token id: Id.Left_Backtick col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: '`' ) child: (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 5 line: (SourceLine line_num: 1 content: 'echo hi' src: (source.Reparsed what: backticks left_token: (Token id: Id.Left_Backtick col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: '`' ) right_token: (Token id: Id.Backtick_Right col: 13 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: '`' ) ) ) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 5 line: (SourceLine line_num: 1 content: 'echo hi' src: (source.Reparsed what: backticks left_token: (Token id: Id.Left_Backtick col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: '`' ) right_token: (Token id: Id.Backtick_Right col: 13 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: '`' ) ) ) tval: echo ) ] ) (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 5 length: 2 span_id: 7 line: (SourceLine line_num: 1 content: 'echo hi' src: (source.Reparsed what: backticks left_token: (Token id: Id.Left_Backtick col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: '`' ) right_token: (Token id: Id.Backtick_Right col: 13 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: '`' ) ) ) tval: hi ) ] ) ] redirects: [] do_fork: T ) right: (Token id: Id.Backtick_Right col: 13 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo `echo hi`' src:(source.CFlag)) tval: '`' ) ) ] ) ] redirects: [] do_fork: T ) ===== CASE: -n -c echo "foo = `echo hi`" ===== (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (DoubleQuoted left: (Token id: Id.Left_DoubleQuote col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '"' ) parts: [ (Token id: Id.Lit_Chars col: 6 length: 6 span_id: 3 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: 'foo = ' ) (CommandSub left_token: (Token id: Id.Left_Backtick col: 12 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '`' ) child: (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 7 line: (SourceLine line_num: 1 content: 'echo hi' src: (source.Reparsed what: backticks left_token: (Token id: Id.Left_Backtick col: 12 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '`' ) right_token: (Token id: Id.Backtick_Right col: 20 length: 1 span_id: 6 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '`' ) ) ) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 7 line: (SourceLine line_num: 1 content: 'echo hi' src: (source.Reparsed what: backticks left_token: (Token id: Id.Left_Backtick col: 12 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '`' ) right_token: (Token id: Id.Backtick_Right col: 20 length: 1 span_id: 6 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '`' ) ) ) tval: echo ) ] ) (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 5 length: 2 span_id: 9 line: (SourceLine line_num: 1 content: 'echo hi' src: (source.Reparsed what: backticks left_token: (Token id: Id.Left_Backtick col: 12 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '`' ) right_token: (Token id: Id.Backtick_Right col: 20 length: 1 span_id: 6 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '`' ) ) ) tval: hi ) ] ) ] redirects: [] do_fork: T ) right: (Token id: Id.Backtick_Right col: 20 length: 1 span_id: 6 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '`' ) ) ] right: (Token id: Id.Right_DoubleQuote col: 21 length: 1 span_id: 11 line: (SourceLine line_num:1 content:'echo "foo = `echo hi`"' src:(source.CFlag)) tval: '"' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (Token id: Id.Lit_Dollar col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo $' src:(source.CFlag)) tval: '$' ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $:' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo $:' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (Token id: Id.Lit_Dollar col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo $:' src:(source.CFlag)) tval: '$' ) (Token id: Id.Lit_Colon col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo $:' src:(source.CFlag)) tval: ':' ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "$"' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "$"' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (DoubleQuoted left: (Token id: Id.Left_DoubleQuote col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo "$"' src:(source.CFlag)) tval: '"' ) parts: [ (Token id: Id.Lit_Dollar col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo "$"' src:(source.CFlag)) tval: '$' ) ] right: (Token id: Id.Right_DoubleQuote col: 7 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo "$"' src:(source.CFlag)) tval: '"' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "$:"' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "$:"' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (DoubleQuoted left: (Token id: Id.Left_DoubleQuote col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo "$:"' src:(source.CFlag)) tval: '"' ) parts: [ (Token id: Id.Lit_Dollar col: 6 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo "$:"' src:(source.CFlag)) tval: '$' ) (Token id: Id.Lit_Chars col: 7 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo "$:"' src:(source.CFlag)) tval: ':' ) ] right: (Token id: Id.Right_DoubleQuote col: 8 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo "$:"' src:(source.CFlag)) tval: '"' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo ${x:-$}' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo ${x:-$}' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (BracedVarSub left: (Token id: Id.Left_DollarBrace col: 5 length: 2 span_id: 2 line: (SourceLine line_num:1 content:'echo ${x:-$}' src:(source.CFlag)) tval: '${' ) token: (Token id: Id.VSub_Name col: 7 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo ${x:-$}' src:(source.CFlag)) tval: x ) var_name: x suffix_op: (suffix_op.Unary op: (Token id: Id.VTest_ColonHyphen col: 8 length: 2 span_id: 4 line: (SourceLine line_num:1 content:'echo ${x:-$}' src:(source.CFlag)) tval: _ ) arg_word: (CompoundWord parts: [ (Token id: Id.Lit_Dollar col: 10 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo ${x:-$}' src:(source.CFlag)) tval: '$' ) ] ) ) right: (Token id: Id.Right_DollarBrace col: 11 length: 1 span_id: 6 line: (SourceLine line_num:1 content:'echo ${x:-$}' src:(source.CFlag)) tval: '}' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo ${x:-$:}' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo ${x:-$:}' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (BracedVarSub left: (Token id: Id.Left_DollarBrace col: 5 length: 2 span_id: 2 line: (SourceLine line_num:1 content:'echo ${x:-$:}' src:(source.CFlag)) tval: '${' ) token: (Token id: Id.VSub_Name col: 7 length: 1 span_id: 3 line: (SourceLine line_num:1 content:'echo ${x:-$:}' src:(source.CFlag)) tval: x ) var_name: x suffix_op: (suffix_op.Unary op: (Token id: Id.VTest_ColonHyphen col: 8 length: 2 span_id: 4 line: (SourceLine line_num:1 content:'echo ${x:-$:}' src:(source.CFlag)) tval: _ ) arg_word: (CompoundWord parts: [ (Token id: Id.Lit_Dollar col: 10 length: 1 span_id: 5 line: (SourceLine line_num:1 content:'echo ${x:-$:}' src:(source.CFlag)) tval: '$' ) (Token id: Id.Lit_Chars col: 11 length: 1 span_id: 6 line: (SourceLine line_num:1 content:'echo ${x:-$:}' src:(source.CFlag)) tval: ':' ) ] ) ) right: (Token id: Id.Right_DollarBrace col: 12 length: 1 span_id: 7 line: (SourceLine line_num:1 content:'echo ${x:-$:}' src:(source.CFlag)) tval: '}' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "${x:-$}"' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "${x:-$}"' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (DoubleQuoted left: (Token id: Id.Left_DoubleQuote col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo "${x:-$}"' src:(source.CFlag)) tval: '"' ) parts: [ (BracedVarSub left: (Token id: Id.Left_DollarBrace col: 6 length: 2 span_id: 3 line: (SourceLine line_num:1 content:'echo "${x:-$}"' src:(source.CFlag)) tval: '${' ) token: (Token id: Id.VSub_Name col: 8 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo "${x:-$}"' src:(source.CFlag)) tval: x ) var_name: x suffix_op: (suffix_op.Unary op: (Token id: Id.VTest_ColonHyphen col: 9 length: 2 span_id: 5 line: (SourceLine line_num:1 content:'echo "${x:-$}"' src:(source.CFlag)) tval: _ ) arg_word: (CompoundWord parts: [ (Token id: Id.Lit_Dollar col: 11 length: 1 span_id: 6 line: (SourceLine line_num:1 content:'echo "${x:-$}"' src:(source.CFlag)) tval: '$' ) ] ) ) right: (Token id: Id.Right_DollarBrace col: 12 length: 1 span_id: 7 line: (SourceLine line_num:1 content:'echo "${x:-$}"' src:(source.CFlag)) tval: '}' ) ) ] right: (Token id: Id.Right_DoubleQuote col: 13 length: 1 span_id: 8 line: (SourceLine line_num:1 content:'echo "${x:-$}"' src:(source.CFlag)) tval: '"' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (DoubleQuoted left: (Token id: Id.Left_DoubleQuote col: 5 length: 1 span_id: 2 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: '"' ) parts: [ (BracedVarSub left: (Token id: Id.Left_DollarBrace col: 6 length: 2 span_id: 3 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: '${' ) token: (Token id: Id.VSub_Name col: 8 length: 1 span_id: 4 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: x ) var_name: x suffix_op: (suffix_op.Unary op: (Token id: Id.VTest_ColonHyphen col: 9 length: 2 span_id: 5 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: _ ) arg_word: (CompoundWord parts: [ (Token id: Id.Lit_Dollar col: 11 length: 1 span_id: 6 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: '$' ) (Token id: Id.Lit_Chars col: 12 length: 1 span_id: 7 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: ':' ) ] ) ) right: (Token id: Id.Right_DollarBrace col: 13 length: 1 span_id: 8 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: '}' ) ) ] right: (Token id: Id.Right_DoubleQuote col: 14 length: 1 span_id: 9 line: (SourceLine line_num:1 content:'echo "${x:-$:}"' src:(source.CFlag)) tval: '"' ) ) ] ) ] 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: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo \\. \\- \\/ \\a \\Z \\0 \\9' src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts: [ (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:'echo \\. \\- \\/ \\a \\Z \\0 \\9' src:(source.CFlag)) tval: echo ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id: Id.Lit_EscapedChar col: 5 length: 2 span_id: 2 line: (SourceLine line_num:1 content:'echo \\. \\- \\/ \\a \\Z \\0 \\9' src:(source.CFlag)) tval: '\\.' ) ch: . ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id: Id.Lit_EscapedChar col: 8 length: 2 span_id: 4 line: (SourceLine line_num:1 content:'echo \\. \\- \\/ \\a \\Z \\0 \\9' src:(source.CFlag)) tval: '\\-' ) ch: - ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id: Id.Lit_EscapedChar col: 11 length: 2 span_id: 6 line: (SourceLine line_num:1 content:'echo \\. \\- \\/ \\a \\Z \\0 \\9' src:(source.CFlag)) tval: '\\/' ) ch: '/' ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id: Id.Lit_EscapedChar col: 14 length: 2 span_id: 8 line: (SourceLine line_num:1 content:'echo \\. \\- \\/ \\a \\Z \\0 \\9' src:(source.CFlag)) tval: '\\a' ) ch: a ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id: Id.Lit_EscapedChar col: 17 length: 2 span_id: 10 line: (SourceLine line_num:1 content:'echo \\. \\- \\/ \\a \\Z \\0 \\9' src:(source.CFlag)) tval: '\\Z' ) ch: Z ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id: Id.Lit_EscapedChar col: 20 length: 2 span_id: 12 line: (SourceLine line_num:1 content:'echo \\. \\- \\/ \\a \\Z \\0 \\9' src:(source.CFlag)) tval: '\\0' ) ch: 0 ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id: Id.Lit_EscapedChar col: 23 length: 2 span_id: 14 line: (SourceLine line_num:1 content:'echo \\. \\- \\/ \\a \\Z \\0 \\9' src:(source.CFlag)) tval: '\\9' ) ch: 9 ) ] ) ] redirects: [] do_fork: T ) ===== CASE: -n -c ((1 > 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: [] ) ===== 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: (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 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 <