ninja: no work to do. *** Running test-arglist ===== CASE: -n -c json write () ===== json write () ^ [ -c flag ]:1: Empty arg list not allowed ===== CASE: -n -c p (; n=42) ===== (command.Simple blame_tok:

more_env: [] words: [{

}] redirects: [] typed_args: (ArgList left: pos_args: [] semi_tok: named_args: [ (NamedArg name: value: (expr.Const c: val:(value.Int i:42)) ) ] right: ) do_fork: T ) ===== CASE: -n -c = f(; n=42) ===== (command.Expr keyword: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c: val:(value.Int i:42))] named_args: [] right: ) do_fork: T ) terminator: ) (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c: val:(value.Int i:43))] named_args: [] right: ) do_fork: T ) ] ) OK test-bug-1850 *** Running test-bug_1825_backslashes ===== CASE: -n -c echo $'trailing\ ' ===== (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:"echo $'trailing\\\n" src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts:[...0x13fe]) (CompoundWord parts: [ (SingleQuoted left: (Token id: Id.Left_DollarSingleQuote col: 5 length: 2 span_id: 2 line: ...0x1406 tval: "$'" ) tokens: [ (Token id: Id.Char_Literals col: 7 length: 8 span_id: 3 line: ...0x1406 tval: trailing ) (Token id: Id.Unknown_Backslash col: 15 length: 2 span_id: 4 line: ...0x1406 tval: "\\\n" ) ] right: (Token id: Id.Right_SingleQuote col: 0 length: 1 span_id: 5 line: (SourceLine line_num:2 content:"'" src:...0x3ffffffc) tval: "'" ) ) ] ) ] redirects: [] do_fork: T ) ===== CASE: -n -c echo $'trailing\\ ' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [ ] right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo $'trailing\ ' ===== echo $'trailing\ ^~ [ -c flag ]:1: Invalid char escape in C-style string literal (OILS-ERR-11) ===== CASE: -n -c setvar x = $'trailing\ ' ===== setvar x = $'trailing\ ^~ [ -c flag ]:1: Invalid char escape in C-style string literal (OILS-ERR-11) OK test-bug_1825_backslashes *** Running test-destructure ===== CASE: -n -c func f() { const x, y = 3, 4 #setvar x = 5 setvar y = 6 } ===== const x, y = 3, 4 ^~~~~ [ -c flag ]:3: const can't be inside proc or func. Use var instead. ===== CASE: -n -c func f() { var x, y = 3, 4 var y = 6 } ===== var y = 6 ^ [ -c flag ]:5: 'y' was already declared ===== CASE: -n -c func f() { var x, y = 3, 4 const y = 6 } ===== const y = 6 ^~~~~ [ -c flag ]:5: const can't be inside proc or func. Use var instead. OK test-destructure *** Running test-eggex-capture ===== CASE: -n -c = / d+ / ===== (command.Expr keyword: / ===== (command.Expr keyword: / ===== (command.Expr keyword: e: (Eggex left: regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:)) flags: [(EggexFlag negated:F flag:)] canonical_flags: i ) ) ===== CASE: -n -c = / d+ ; !i / ===== = / d+ ; !i / ^ [ -c flag ]:1: Flag can't be negated ===== CASE: -n -c = / d+ ; reg_oops / ===== = / d+ ; reg_oops / ^~~~~~~~ [ -c flag ]:1: Invalid regex flag 'reg_oops' ===== CASE: -n -c = / d+ ; !i; PCRE / ===== (command.Expr keyword: e: (Eggex left: regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:)) flags: [(EggexFlag negated:F flag:)] trans_pref: ) ) ===== CASE: -n -c = / d+ ; i reg_newline ; ERE / ===== (command.Expr keyword: e: (Eggex left: regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:)) flags: [] trans_pref: canonical_flags: "" ) ) ===== CASE: -n -c = / d+ ; / ===== (command.Expr keyword: trim() ===== (command.VarDecl keyword: lhs: [(NameType left: name:x)] rhs: (expr.FuncCall func: (Attribute obj: (expr.Var left: name:s) op: "> attr: attr_name: trim ctx: expr_context.Store ) args: (ArgList left: pos_args:[] named_args:[] right:) ) ) ===== CASE: -n -c func f(x Int) => List[Int] { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [ (Param blame_tok: name: x type: (TypeExpr tok: name:Int) ) ] ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) OK test-fat-arrow *** Running test-float-literals ===== CASE: -n -c = 42.0 ===== (command.Expr keyword: e: (expr.Const c: val:(value.Float f:420.0)) ) ===== CASE: -n -c = 42_.0 ===== = 42_.0 ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt) ===== CASE: -n -c = 42. ===== = 42. ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c = .333 ===== = .333 ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_Dot) ===== CASE: -n -c = _42.0 ===== = _42.0 ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt) OK test-float-literals *** Running test-for-parse-bare-word ===== 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: [{} {(N 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: [{} {(N 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: [{} {(N Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) OK test-for-parse-bare-word *** Running test-func-def ===== CASE: -n -c func f(p) { var p = foo } ===== func f(p) { var p = foo } ^ [ -c flag ]:1: 'p' was already declared ===== CASE: -n -c func f(p; n) { var n = foo } ===== func f(p; n) { var n = foo } ^ [ -c flag ]:1: 'n' was already declared OK test-func-def *** Running test-func-sig ===== CASE: -n -c func f { echo hi } ===== func f { echo hi } ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_LBrace) ===== CASE: -n -c func f () { echo hi } ===== (Func keyword: name: body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (a List[Int] = [3,4]) { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [ (Param blame_tok: name: a type: (TypeExpr tok: name: List params: [(TypeExpr tok: name:Int)] ) default_val: (expr.List left: elts: [ (expr.Const c: val:(value.Int i:3)) (expr.Const c: val:(value.Int i:4)) ] ctx: expr_context.Store ) ) ] ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (a, b, ...rest; c) { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [(Param blame_tok: name:a) (Param blame_tok: name:b)] rest_of: (RestParam blame_tok: name:rest) ) named: (ParamGroup params:[(Param blame_tok: name:c)]) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (a, b, ...rest; c, ...named) { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [(Param blame_tok: name:a) (Param blame_tok: name:b)] rest_of: (RestParam blame_tok: name:rest) ) named: (ParamGroup params: [(Param blame_tok: name:c)] rest_of: (RestParam blame_tok: name:named) ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (a, b, ...rest; c, ...named;) { echo hi } ===== func f (a, b, ...rest; c, ...named;) { echo hi } ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_Semi) OK test-func-sig *** Running test-func-var-checker ===== CASE: -n -c func f(x) { setvar x = true } ===== (Func keyword: name: positional: (ParamGroup params:[(Param blame_tok: name:x)]) body: (BraceGroup left: children: [ (command.Mutation keyword: lhs: [(N Id.Expr_Name x)] op: rhs: (expr.Const c: val:(value.Bool b:T)) ) ] redirects: [] right: ) ) ===== CASE: -n -c func f() { setvar x = true } ===== setvar x = true ^ [ -c flag ]:3: setvar couldn't find matching 'var x' (OILS-ERR-10) OK test-func-var-checker *** Running test-hay-assign ===== CASE: -n -c name = val ===== name = val ^ [ -c flag ]:2: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c rule { x = 42 } ===== x = 42 ^ [ -c flag ]:3: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c RULE { x = 42 } ===== x = 42 ^ [ -c flag ]:3: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c Rule { x = 42 } ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.VarDecl lhs: [(NameType left: name:x)] rhs: (expr.Const c: val:(value.Int i:42)) ) ] redirects: [] right: ) lines: [ (SourceLine line_num:2 content:"Rule {\n" src:(source__CFlag)) (SourceLine line_num:3 content:" x = 42\n" src:...0x7f787ae87c50) (SourceLine line_num:4 content:"}\n" src:...0x7f787ae87c50) ] ) do_fork: T ) ===== CASE: -n -c Rule X Y { x = 42 } ===== (command.Simple blame_tok: more_env: [] words: [{} {} {}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.VarDecl lhs: [(NameType left: name:x)] rhs: (expr.Const c: val:(value.Int i:42)) ) ] redirects: [] right: ) lines: [ (SourceLine line_num:2 content:"Rule X Y {\n" src:(source__CFlag)) (SourceLine line_num:3 content:" x = 42\n" src:...0x7fc263593c90) (SourceLine line_num:4 content:"}\n" src:...0x7fc263593c90) ] ) do_fork: T ) ===== CASE: -n -c RULe { # inconsistent but OK x = 42 } ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.VarDecl lhs: [(NameType left: name:x)] rhs: (expr.Const c: val:(value.Int i:42)) ) ] redirects: [] right: ) lines: [ (SourceLine line_num:2 content:"RULe { # inconsistent but OK\n" src:(source__CFlag)) (SourceLine line_num:3 content:" x = 42\n" src:...0x7fb6deed7c50) (SourceLine line_num:4 content:"}\n" src:...0x7fb6deed7c50) ] ) do_fork: T ) ===== CASE: -n -c hay eval :result { Rule { foo = 42 } bar = 43 # parse error here } ===== bar = 43 # parse error here ^ [ -c flag ]:8: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c hay define TASK TASK build { foo = 42 } ===== foo = 42 ^ [ -c flag ]:5: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c hay define Package/TASK Package libc { TASK build { # this is not an attribute, should not be valid foo = 42 } } ===== foo = 42 ^ [ -c flag ]:7: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c hay define Rule Rule { return (x) } ===== return (x) ^ [ -c flag ]:5: Typed return is only allowed inside func OK test-hay-assign *** Running test-hay-shell-assign ===== CASE: -n -c hay define Package Package foo { version=1 } ===== version=1 ^~~~~~~~ [ -c flag ]:5: Use var/setvar to assign in YSH ===== CASE: -n -c hay define Package/User Package foo { User bob { sudo=1 } } ===== sudo=1 ^~~~~ [ -c flag ]:6: Use var/setvar to assign in YSH ===== CASE: -n -c hay define Package/SHELL/User Package foo { SHELL bob { sudo=1 User { name = "z" } } } ===== (command.CommandList children: [ (command.Simple blame_tok: more_env: [] words: [{} {} { }] redirects: [] do_fork: T ) (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.ShAssignment left: children: [ (command.VarDecl lhs: [(NameType left: name:name)] rhs: (DQ ) ) ] redirects: [] right: ) lines: [ (SourceLine line_num: 7 content: " User {\n" src: (source__CFlag) ) (SourceLine line_num: 8 content: " name = \"z\"\n" src: ...0x7ff0c05fdc50 ) (SourceLine line_num: 9 content: " }\n" src: ...0x7ff0c05fdc50 ) ] ) do_fork: T ) ] redirects: [] right: ) lines: [] ) do_fork: T ) ] redirects: [] right: ) lines: [] ) do_fork: T ) ] ) ===== CASE: -n -c hay define Package/SHELL/User Package foo { SHELL bob { # Disallowed # a = b User { x=1 } } } ===== x=1 ^~ [ -c flag ]:9: Use var/setvar to assign in YSH OK test-hay-shell-assign *** Running test-int-literals ===== CASE: -n -c = 42 ===== (command.Expr keyword: e:(expr.Const c: val:(value.Int i:420))) ===== CASE: -n -c = 42_ ===== = 42_ ^ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = 42_0_ ===== = 42_0_ ^ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = _42 ===== (command.Expr keyword: child: (expr.FuncCall func: (expr.Var left: name:sorted) args: (ArgList left: pos_args: [(expr.Var left: name:x)] 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 left: name:sorted) args: (ArgList left: pos_args: [(expr.Var left: name:x)] 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 OK test-invalid_parens *** Running test-lazy-arg-list ===== CASE: -n -c assert [42 === x] ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [ (expr.Compare left: (expr.Const c: val:(value.Int i:42)) ops: [] comparators: [(expr.Var left: name:x)] ) ] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c assert [ 42 === x ] ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [ (expr.Compare left: (expr.Const c: val:(value.Int i:42)) ops: [] comparators: [(expr.Var left: name:x)] ) ] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c assert [42, 43] ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [ (expr.Const c: val:(value.Int i:42)) (expr.Const c: val:(value.Int i:43)) ] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c assert [42, named=true] ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c: val:(value.Int i:42))] named_args: [ (NamedArg name: value: (expr.Const c: val:(value.Bool b:T)) ) ] right: ) do_fork: T ) ===== CASE: -n -c assert [42, named=true]; echo hi ===== (command.CommandList children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c: val:(value.Int i:42))] named_args: [ (NamedArg name: value: (expr.Const c: val:(value.Bool b:T)) ) ] right: ) do_fork: T ) terminator: ) (command.Simple blame_tok: more_env:[] words:[{} {}] redirects:[] do_fork:T) ] ) ===== CASE: -n -c assert [42, named=true] { echo hi } ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c: val:(value.Int i:42))] named_args: [ (NamedArg name: value: (expr.Const c: val:(value.Bool b:T)) ) ] right: ) block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [(SourceLine line_num:1 content:"assert [42, named=true] { echo hi }" src:(source__CFlag))] ) do_fork: T ) ===== CASE: -n -c assert [42, named=true]{ echo hi } ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c: val:(value.Int i:42))] named_args: [ (NamedArg name: value: (expr.Const c: val:(value.Bool b:T)) ) ] right: ) block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [(SourceLine line_num:1 content:"assert [42, named=true]{ echo hi }" src:(source__CFlag))] ) do_fork: T ) ===== CASE: -n -c assert *.[ch] ===== (command.Simple blame_tok: more_env: [] words: [{} { <.> }] redirects: [] do_fork: T ) ===== CASE: -n -c assert 42[ch] ===== (command.Simple blame_tok: more_env: [] words: [{} {<42> }] redirects: [] do_fork: T ) ===== CASE: -n -c echo[] ===== (command.Simple blame_tok: more_env: [] words: [{ }] redirects: [] do_fork: T ) ===== CASE: -n -c assert [4 ===== assert [4 ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c assert [ 4 ===== assert [ 4 ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c json write (42) >out ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [(Redir op:"> loc:(redir_loc.Fd fd:1) arg:{})] typed_args: (ArgList left: pos_args: [(expr.Const c: val:(value.Int i:42))] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c json write >out (42) ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [(Redir op:"> loc:(redir_loc.Fd fd:1) arg:{})] typed_args: (ArgList left: pos_args: [(expr.Const c: val:(value.Int i:42))] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c [ x = y ] ===== (command.Simple blame_tok: more_env: [] words: [{} {} {}] redirects: [] do_fork: T ) OK test-lazy-arg-list *** Running test-make-these-nicer ===== CASE: -n -c = ===== = ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c call ===== call ^ [ -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) OK test-make-these-nicer *** Running test-multiline-string ===== CASE: -n -c echo u''' hi ''' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [] right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo b''' hi ''' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [] right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo b''' hi '' ===== echo b''' ^ [ -c flag ]:1: Unexpected EOF in single-quoted string that began here ===== CASE: -n -c echo r''' hi '''bad ===== '''bad ^~~ [ -c flag ]:3: Unexpected token after YSH single-quoted string ===== CASE: -n -c echo u''' hi '''bad ===== '''bad ^~~ [ -c flag ]:3: Unexpected token after YSH single-quoted string ===== CASE: -n -c echo """ hi """bad ===== """bad ^~~ [ -c flag ]:3: Unexpected parts after triple quoted string OK test-multiline-string *** Running test-no-const ===== CASE: -n -c const x = 42 ===== (command.VarDecl keyword: lhs: [(NameType left: name:x)] rhs: (expr.Const c: val:(value.Int i:42)) ) ===== CASE: -n -c proc p { const x = 42 } ===== const x = 42 ^~~~~ [ -c flag ]:3: const can't be inside proc or func. Use var instead. ===== CASE: -n -c func f() { const x = 42 } ===== const x = 42 ^~~~~ [ -c flag ]:3: const can't be inside proc or func. Use var instead. OK test-no-const *** Running test-parse-at ===== CASE: -n -c echo @ ===== echo @ ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) ===== CASE: -n -c echo @@ ===== echo @@ ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) ===== CASE: -n -c echo @{foo} ===== echo @{foo} ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) ===== CASE: -n -c echo @/foo/ ===== echo @/foo/ ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) ===== CASE: -n -c echo @"foo" ===== echo @"foo" ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) OK test-parse-at *** Running test-parse-backslash ===== 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 left:)}] 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 in unquoted word (OILS-ERR-13) ===== CASE: -n -c echo \- ===== echo \- ^~ [ -c flag ]:1: Invalid char escape in unquoted word (OILS-ERR-13) ===== CASE: -n -c echo \/ ===== echo \/ ^~ [ -c flag ]:1: Invalid char escape in unquoted word (OILS-ERR-13) ===== CASE: -n -c echo \a ===== echo \a ^~ [ -c flag ]:1: Invalid char escape in unquoted word (OILS-ERR-13) ===== CASE: -n -c echo \Z ===== echo \Z ^~ [ -c flag ]:1: Invalid char escape in unquoted word (OILS-ERR-13) ===== CASE: -n -c echo \0 ===== echo \0 ^~ [ -c flag ]:1: Invalid char escape in unquoted word (OILS-ERR-13) ===== CASE: -n -c echo \9 ===== echo \9 ^~ [ -c flag ]:1: Invalid char escape in unquoted word (OILS-ERR-13) ===== 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:[...0x1402]) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar col:5 length:2 span_id:2 line:...0x140a tval:"\\.") ch: . ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar col:8 length:2 span_id:4 line:...0x140a tval:"\\-") ch: - ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar col:11 length:2 span_id:6 line:...0x140a tval:"\\/") ch: / ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar col:14 length:2 span_id:8 line:...0x140a tval:"\\a") ch: a ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar col:17 length:2 span_id:10 line:...0x140a tval:"\\Z") ch: Z ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar col:20 length:2 span_id:12 line:...0x140a tval:"\\0") ch: 0 ) ] ) (CompoundWord parts: [ (word_part.EscapedLiteral token: (Token id:Id.Lit_EscapedChar col:23 length:2 span_id:14 line:...0x140a tval:"\\9") ch: 9 ) ] ) ] redirects: [] do_fork: T ) OK test-parse-backslash *** Running test-parse-brace ===== CASE: -n -c if test -f foo{ echo hi } ===== if test -f foo{ echo hi } ^~~ [ -c flag ]:1: Word has unbalanced { }. Maybe add a space or quote it like \{ OK test-parse-brace *** Running test-parse_dollar ===== 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:[...0x1406]) (CompoundWord parts: [(Token id:Id.Lit_Dollar col:5 length:1 span_id:2 line:...0x140e tval:"$")] ) ] redirects: [] do_fork: T ) ===== CASE: +O test-parse_dollar -n -c echo $ ===== oils: got invalid option 'test-parse_dollar' ===== 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:[...0x1406]) (CompoundWord parts: [ (Token id:Id.Lit_Dollar col:5 length:1 span_id:2 line:...0x140e tval:"$") (Token id:Id.Lit_Colon col:6 length:1 span_id:3 line:...0x140e tval:":") ] ) ] redirects: [] do_fork: T ) ===== CASE: +O test-parse_dollar -n -c echo $: ===== oils: got invalid option 'test-parse_dollar' ===== 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:[...0x1402]) (CompoundWord parts: [ (DoubleQuoted left: (Token id:Id.Left_DoubleQuote col:5 length:1 span_id:2 line:...0x140a tval:"\"") parts: [(Token id:Id.Lit_Dollar col:6 length:1 span_id:3 line:...0x140a tval:"$")] right: (Token id:Id.Right_DoubleQuote col:7 length:1 span_id:4 line:...0x140a tval:"\"") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: +O test-parse_dollar -n -c echo "$" ===== oils: got invalid option 'test-parse_dollar' ===== 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:[...0x1402]) (CompoundWord parts: [ (DoubleQuoted left: (Token id:Id.Left_DoubleQuote col:5 length:1 span_id:2 line:...0x140a tval:"\"") parts: [ (Token id:Id.Lit_Dollar col:6 length:1 span_id:3 line:...0x140a tval:"$") (Token id:Id.Lit_Chars col:7 length:1 span_id:4 line:...0x140a tval:":") ] right: (Token id:Id.Right_DoubleQuote col:8 length:1 span_id:5 line:...0x140a tval:"\"") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: +O test-parse_dollar -n -c echo "$:" ===== oils: got invalid option 'test-parse_dollar' ===== 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:[...0x1402]) (CompoundWord parts: [ (BracedVarSub left: (Token id:Id.Left_DollarBrace col:5 length:2 span_id:2 line:...0x140a tval:"${") token: (Token id:Id.VSub_Name col:7 length:1 span_id:3 line:...0x140a tval:x) var_name: x suffix_op: (suffix_op.Unary op: (Token id:Id.VTest_ColonHyphen col:8 length:2 span_id:4 line:...0x140a) arg_word: (CompoundWord parts: [(Token id:Id.Lit_Dollar col:10 length:1 span_id:5 line:...0x140a tval:"$")] ) ) right: (Token id:Id.Right_DollarBrace col:11 length:1 span_id:6 line:...0x140a tval:"}") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: +O test-parse_dollar -n -c echo ${x:-$} ===== oils: got invalid option 'test-parse_dollar' ===== 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:[...0x1402]) (CompoundWord parts: [ (BracedVarSub left: (Token id:Id.Left_DollarBrace col:5 length:2 span_id:2 line:...0x140a tval:"${") token: (Token id:Id.VSub_Name col:7 length:1 span_id:3 line:...0x140a tval:x) var_name: x suffix_op: (suffix_op.Unary op: (Token id:Id.VTest_ColonHyphen col:8 length:2 span_id:4 line:...0x140a) arg_word: (CompoundWord parts: [ (Token id: Id.Lit_Dollar col: 10 length: 1 span_id: 5 line: ...0x140a tval: "$" ) (Token id: Id.Lit_Chars col: 11 length: 1 span_id: 6 line: ...0x140a tval: ":" ) ] ) ) right: (Token id:Id.Right_DollarBrace col:12 length:1 span_id:7 line:...0x140a tval:"}") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: +O test-parse_dollar -n -c echo ${x:-$:} ===== oils: got invalid option 'test-parse_dollar' ===== 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:[...0x1402]) (CompoundWord parts: [ (DoubleQuoted left: (Token id:Id.Left_DoubleQuote col:5 length:1 span_id:2 line:...0x140a tval:"\"") parts: [ (BracedVarSub left: (Token id:Id.Left_DollarBrace col:6 length:2 span_id:3 line:...0x140a tval:"${") token: (Token id:Id.VSub_Name col:8 length:1 span_id:4 line:...0x140a tval:x) var_name: x suffix_op: (suffix_op.Unary op: (Token id:Id.VTest_ColonHyphen col:9 length:2 span_id:5 line:...0x140a) arg_word: (CompoundWord parts: [ (Token id: Id.Lit_Dollar col: 11 length: 1 span_id: 6 line: ...0x140a tval: "$" ) ] ) ) right: (Token id: Id.Right_DollarBrace col: 12 length: 1 span_id: 7 line: ...0x140a tval: "}" ) ) ] right: (Token id:Id.Right_DoubleQuote col:13 length:1 span_id:8 line:...0x140a tval:"\"") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: +O test-parse_dollar -n -c echo "${x:-$}" ===== oils: got invalid option 'test-parse_dollar' ===== 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:[...0x1402]) (CompoundWord parts: [ (DoubleQuoted left: (Token id:Id.Left_DoubleQuote col:5 length:1 span_id:2 line:...0x140a tval:"\"") parts: [ (BracedVarSub left: (Token id:Id.Left_DollarBrace col:6 length:2 span_id:3 line:...0x140a tval:"${") token: (Token id:Id.VSub_Name col:8 length:1 span_id:4 line:...0x140a tval:x) var_name: x suffix_op: (suffix_op.Unary op: (Token id:Id.VTest_ColonHyphen col:9 length:2 span_id:5 line:...0x140a) arg_word: (CompoundWord parts: [ (Token id: Id.Lit_Dollar col: 11 length: 1 span_id: 6 line: ...0x140a tval: "$" ) (Token id: Id.Lit_Chars col: 12 length: 1 span_id: 7 line: ...0x140a tval: ":" ) ] ) ) right: (Token id: Id.Right_DollarBrace col: 13 length: 1 span_id: 8 line: ...0x140a tval: "}" ) ) ] right: (Token id:Id.Right_DoubleQuote col:14 length:1 span_id:9 line:...0x140a tval:"\"") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: +O test-parse_dollar -n -c echo "${x:-$:}" ===== oils: got invalid option 'test-parse_dollar' ===== CASE: -n -c echo "${x:-$:}" ===== echo "${x:-$:}" ^ [ -c flag ]:1: Literal $ should be quoted like \$ OK test-parse_dollar *** Running test-parse_dparen ===== 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)) ) 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:...0x140a tval:1)] ) right: (CompoundWord parts: [(Token id:Id.Lit_Digits col:6 length:1 span_id:5 line:...0x140a 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:...0x140a tval:43)] ) right: (CompoundWord parts: [(Token id:Id.Lit_Digits col:16 length:2 span_id:13 line:...0x140a tval:42)] ) ) ) right: (Token id:Id.Op_DRightParen col:19 length:1 span_id:15 line:...0x140a) 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: ...0x140a cond: (condition.Shell commands: [ (command.Sentence child: (command.DParen left: (Token id:Id.Op_DLeftParen col:3 length:2 span_id:2 line:...0x1412) 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: ...0x1412 tval: 1 ) ] ) right: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 9 length: 1 span_id: 7 line: ...0x1412 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: ...0x1412 tval: 43 ) ] ) right: (CompoundWord parts: [ (Token id: Id.Lit_Digits col: 19 length: 2 span_id: 15 line: ...0x1412 tval: 42 ) ] ) ) ) right: (Token id:Id.Op_DRightParen col:22 length:1 span_id:17 line:...0x1412) redirects: [] ) terminator: (Token id:Id.Op_Semi col:23 length:1 span_id:18 line:...0x1412) ) ] ) then_kw: (Token id:Id.KW_Then col:25 length:4 span_id:20 line:...0x1412 tval:then) action: [ (command.Sentence child: (command.Simple blame_tok: (Token id:Id.Lit_Chars col:30 length:4 span_id:22 line:...0x1412 tval:echo) more_env: [] words: [ (CompoundWord parts:[...0x1372]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:35 length:3 span_id:24 line:...0x1412 tval:yes)] ) ] redirects: [] do_fork: T ) terminator: (Token id:Id.Op_Semi col:38 length:1 span_id:25 line:...0x1412) ) ] spids: [0 20] ) ] else_action: [] fi_kw: (Token id:Id.KW_Fi col:40 length:2 span_id:27 line:...0x1412 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: (NameTok left: (Token id:Id.Lit_ArithVarLike col:6 length:1 span_id:3 line:...0x1412 tval:x) var_name: x ) right: (CompoundWord parts: [(Token id:Id.Lit_Digits col:10 length:1 span_id:7 line:...0x1412 tval:1)] ) ) cond: (arith_expr.Binary op_id: Id.Arith_Less left: (NameTok left: (Token id:Id.Lit_ArithVarLike col:13 length:1 span_id:10 line:...0x1412 tval:x) var_name: x ) right: (CompoundWord parts: [(Token id:Id.Lit_Digits col:17 length:1 span_id:14 line:...0x1412 tval:5)] ) ) update: (arith_expr.UnaryAssign op_id: Id.Arith_DPlus child: (NameTok left: (Token id:Id.Lit_ArithVarLike col:22 length:1 span_id:18 line:...0x1412 tval:x) var_name: x ) ) body: (command.DoGroup left: (Token id:Id.KW_Do col:27 length:2 span_id:23 line:...0x1412 tval:do) children: [ (command.Sentence child: (command.Simple blame_tok: (Token id:Id.Lit_Chars col:30 length:4 span_id:25 line:...0x1412 tval:echo) more_env: [] words: [ (CompoundWord parts:[...0x137a]) (CompoundWord parts: [ (NameTok left: (Token id: Id.VSub_DollarName col: 35 length: 2 span_id: 27 line: ...0x1412 tval: "$x" ) var_name: x ) ] ) ] redirects: [] do_fork: T ) terminator: (Token id:Id.Op_Semi col:37 length:1 span_id:28 line:...0x1412) ) ] right: (Token id:Id.KW_Done col:39 length:4 span_id:30 line:...0x1412 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: val:(value.Int i:1)) ops: [] comparators: [(expr.Const c: val:(value.Int i:0))] ) right: (expr.Compare left: (expr.Const c: val:(value.Int i:43)) ops: [] comparators: [(expr.Const c: val:(value.Int i:42))] ) ) ) 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: val:(value.Int i:1)) ops: [] comparators: [(expr.Const c: val:(value.Int i:0))] ) right: (expr.Compare left: (expr.Const c: val:(value.Int i:43)) ops: [] comparators: [(expr.Const c: val:(value.Int i:42))] ) ) ) action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] spids: [0] ) ] else_action: [] redirects: [] ) OK test-parse_dparen *** Running test-place-expr ===== CASE: -n -c read (&x) ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Place blame_tok: var_name:x ops:[])] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c read (&x[0]) ===== read (&x[0]) ^ [ -c flag ]:1: Places in containers not implemented yet ===== CASE: -n -c read (&x[0][1]) ===== read (&x[0][1]) ^ [ -c flag ]:1: Places in containers not implemented yet ===== CASE: -n -c read (&x.key.other) ===== read (&x.key.other) ^ [ -c flag ]:1: Places in containers not implemented yet ===== CASE: -n -c read (&x + 1) ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [ (expr.Binary op: left: (expr.Place blame_tok: var_name:x ops:[]) right: (expr.Const c: val:(value.Int i:1)) ) ] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c read (&42) ===== read (&42) ^~ [ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt) ===== CASE: -n -c read (&+) ===== read (&+) ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Plus) ===== CASE: -n -c read (&(x)) ===== read (&(x)) ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_LParen) OK test-place-expr *** Running test-proc-args ===== CASE: -n -c json write (x) ===== (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:"json write (x)" src:(source.CFlag)) tval: json ) more_env: [] words: [ (CompoundWord parts:[...0x1402]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:5 length:5 span_id:2 line:...0x140a tval:write)] ) ] redirects: [] typed_args: (ArgList left: (Token id:Id.Op_LParen col:11 length:1 span_id:4 line:...0x140a) pos_args: [ (expr.Var left: (Token id:Id.Expr_Name col:12 length:1 span_id:5 line:...0x140a tval:x) name: x ) ] named_args: [] right: (Token id:Id.Op_RParen col:13 length:1 span_id:6 line:...0x140a) ) do_fork: T ) ===== CASE: -n -c echo $(json write (x)) ===== (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:"echo $(json write (x))" src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts:[...0x1402]) (CompoundWord parts: [ (CommandSub left_token: (Token id: Id.Left_DollarParen col: 5 length: 2 span_id: 2 line: ...0x140a tval: "$(" ) child: (command.Simple blame_tok: (Token id:Id.Lit_Chars col:7 length:4 span_id:3 line:...0x140a tval:json) more_env: [] words: [ (CompoundWord parts:[...0x13da]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:12 length:5 span_id:5 line:...0x140a tval:write)] ) ] redirects: [] typed_args: (ArgList left: (Token id:Id.Op_LParen col:18 length:1 span_id:7 line:...0x140a) pos_args: [ (expr.Var left: (Token id:Id.Expr_Name col:19 length:1 span_id:8 line:...0x140a tval:x) name: x ) ] named_args: [] right: (Token id:Id.Op_RParen col:20 length:1 span_id:9 line:...0x140a) ) do_fork: T ) right: (Token id:Id.Eof_RParen col:21 length:1 span_id:10 line:...0x140a) ) ] ) ] redirects: [] do_fork: T ) ===== CASE: -n -c var result = $(json write (x)) ===== (command.VarDecl keyword: (Token id: Id.KW_Var col: 0 length: 3 span_id: 0 line: (SourceLine line_num:1 content:"var result = $(json write (x))" src:(source.CFlag)) tval: var ) lhs: [ (NameType left: (Token id:Id.Expr_Name col:4 length:6 span_id:2 line:...0x140e tval:result) name: result ) ] rhs: (CommandSub left_token: (Token id:Id.Left_DollarParen col:13 length:2 span_id:6 line:...0x140e tval:"$(") child: (command.Simple blame_tok: (Token id:Id.Lit_Chars col:15 length:4 span_id:7 line:...0x140e tval:json) more_env: [] words: [ (CompoundWord parts:[...0x1376]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:20 length:5 span_id:9 line:...0x140e tval:write)] ) ] redirects: [] typed_args: (ArgList left: (Token id:Id.Op_LParen col:26 length:1 span_id:11 line:...0x140e) pos_args: [ (expr.Var left: (Token id:Id.Expr_Name col:27 length:1 span_id:12 line:...0x140e tval:x) name: x ) ] named_args: [] right: (Token id:Id.Op_RParen col:28 length:1 span_id:13 line:...0x140e) ) do_fork: T ) right: (Token id:Id.Eof_RParen col:29 length:1 span_id:14 line:...0x140e) ) ) ===== CASE: -n -c json write (x, y); echo hi ===== (command.CommandList children: [ (command.Sentence child: (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:"json write (x, y); echo hi" src:(source.CFlag)) tval: json ) more_env: [] words: [ (CompoundWord parts:[...0x1402]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:5 length:5 span_id:2 line:...0x140a tval:write)] ) ] redirects: [] typed_args: (ArgList left: (Token id:Id.Op_LParen col:11 length:1 span_id:4 line:...0x140a) pos_args: [ (expr.Var left: (Token id:Id.Expr_Name col:12 length:1 span_id:5 line:...0x140a tval:x) name: x ) (expr.Var left: (Token id:Id.Expr_Name col:15 length:1 span_id:8 line:...0x140a tval:y) name: y ) ] named_args: [] right: (Token id:Id.Op_RParen col:16 length:1 span_id:9 line:...0x140a) ) do_fork: T ) terminator: (Token id:Id.Op_Semi col:17 length:1 span_id:10 line:...0x140a) ) (command.Simple blame_tok: (Token id:Id.Lit_Chars col:19 length:4 span_id:12 line:...0x140a tval:echo) more_env: [] words: [ (CompoundWord parts:[...0x1302]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:24 length:2 span_id:14 line:...0x140a tval:hi)] ) ] redirects: [] do_fork: T ) ] ) ===== CASE: -n -c json write (x, name = "value") echo hi ===== (command.CommandList children: [ (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 1 line: (SourceLine line_num:2 content:"json write (x, name = \"value\")\n" src:(source.CFlag)) tval: json ) more_env: [] words: [ (CompoundWord parts:[...0x13fa]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:5 length:5 span_id:3 line:...0x13fe tval:write)] ) ] redirects: [] typed_args: (ArgList left: (Token id:Id.Op_LParen col:11 length:1 span_id:5 line:...0x13fe) pos_args: [ (expr.Var left: (Token id:Id.Expr_Name col:12 length:1 span_id:6 line:...0x13fe tval:x) name: x ) ] named_args: [ (NamedArg name: (Token id:Id.Expr_Name col:15 length:4 span_id:9 line:...0x13fe tval:name) value: (DoubleQuoted left: (Token id: Id.Left_DoubleQuote col: 22 length: 1 span_id: 13 line: ...0x13fe tval: "\"" ) parts: [ (Token id: Id.Lit_Chars col: 23 length: 5 span_id: 14 line: ...0x13fe tval: value ) ] right: (Token id: Id.Right_DoubleQuote col: 28 length: 1 span_id: 15 line: ...0x13fe tval: "\"" ) ) ) ] right: (Token id:Id.Op_RParen col:29 length:1 span_id:16 line:...0x13fe) ) do_fork: T ) (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 18 line: (SourceLine line_num:3 content:"echo hi\n" src:...0x3ffffffc) tval: echo ) more_env: [] words: [ (CompoundWord parts:[...0x1286]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:5 length:2 span_id:20 line:...0x128a tval:hi)] ) ] 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 left: name:x)] named_args: [] right: ) block: (LiteralBlock 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 left: name:x)] named_args: [] right: ) block: (LiteralBlock 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:...0x7fc564197c50) (SourceLine line_num:4 content:"}" src:...0x7fc564197c50) ] ) 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:[...0x1406]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:5 length:5 span_id:2 line:...0x140e tval:write)] ) ] redirects: [] typed_args: (ArgList left: (Token id:Id.Op_LParen col:11 length:1 span_id:4 line:...0x140e) pos_args: [ (expr.Var left: (Token id: Id.Expr_Name col: 4 length: 1 span_id: 7 line: (SourceLine line_num:2 content:" x,\n" src:...0x3ffffffc) tval: x ) name: x ) (expr.Var left: (Token id: Id.Expr_Name col: 4 length: 1 span_id: 11 line: (SourceLine line_num:3 content:" y,\n" src:...0x3ffffffc) tval: y ) name: y ) (expr.Var left: (Token id: Id.Expr_Name col: 4 length: 1 span_id: 15 line: (SourceLine line_num:4 content:" z\n" src:...0x3ffffffc) tval: z ) name: z ) ] named_args: [] right: (Token id: Id.Op_RParen col: 2 length: 1 span_id: 18 line: (SourceLine line_num:5 content:" )" src:...0x3ffffffc) ) ) 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 ( OK test-proc-args *** Running test-proc-def ===== CASE: -n -c proc p(w) { var w = foo } ===== proc p(w) { var w = foo } ^ [ -c flag ]:1: 'w' was already declared ===== CASE: -n -c proc p(w; p) { var p = foo } ===== proc p(w; p) { var p = foo } ^ [ -c flag ]:1: 'p' was already declared ===== CASE: -n -c proc p(w; p; n, n2) { var n2 = foo } ===== proc p(w; p; n, n2) { var n2 = foo } ^~ [ -c flag ]:1: 'n2' was already declared ===== CASE: -n -c proc p(w; p; n, n2; b) { var b = foo } ===== proc p(w; p; n, n2; b) { var b = foo } ^ [ -c flag ]:1: 'b' was already declared OK test-proc-def *** Running test-proc-sig ===== CASE: -n -c proc f[] { echo hi } ===== proc f[] { echo hi } ^~ [ -c flag ]:1: Invalid proc name 'f[' ===== CASE: -n -c proc : { echo hi } ===== proc : { echo hi } ^ [ -c flag ]:1: Invalid proc name ':' ===== CASE: -n -c proc foo::bar { echo hi } ===== proc foo::bar { echo hi } ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Colon) OK test-proc-sig *** Running test-regex-literals ===== CASE: -n -c var x = / ! / ===== var x = / ! / ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Slash) ===== CASE: -n -c var x = / ![a-z] / ===== (command.VarDecl keyword: lhs: [(NameType left: name:x)] rhs: (Eggex left: regex: (re.CharClassLiteral negated: T terms: [(class_literal_term.Range start: end:)] ) flags: [] canonical_flags: "" ) ) ===== CASE: -n -c var x = / !d / ===== (command.VarDecl keyword: lhs: [(NameType left: name:x)] rhs: (Eggex left: regex: (PerlClass negated: name:d) flags: [] canonical_flags: "" ) ) ===== CASE: -n -c var x = / !! / ===== var x = / !! / ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Slash) ===== CASE: -n -c var x = /[a-zA-Z]/ ===== var x = /[a-zA-Z]/ ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Minus) ===== CASE: -n -c var x = /[a-z0-9]/ ===== var x = /[a-z0-9]/ ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Minus) ===== CASE: -n -c var x = /[a-zz]/ ===== var x = /[a-zz]/ ^~ [ -c flag ]:1: Range start/end shouldn't have more than one character ===== CASE: -n -c var x = /['ab'-'z']/ ===== var x = /['ab'-'z']/ ^ [ -c flag ]:1: Range start/end shouldn't have more than one character ===== CASE: -n -c var x = /[$a-${z}]/ ===== var x = /[$a-${z}]/ ^~ [ -c flag ]:1: Syntax error in expression (near Id.VSub_DollarName) ===== CASE: -n -c var x = /[abc]/ ===== var x = /[abc]/ ^~~ [ -c flag ]:1: 'abc' isn't a character class ===== CASE: -n -c var x = /[% _]/ ===== var x = /[% _]/ ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Percent) OK test-regex-literals *** Running test-return-args ===== CASE: -n -c func foo(x) { return (x) } ===== (Func keyword: name: positional: (ParamGroup params:[(Param blame_tok: name:x)]) body: (BraceGroup left: children: [ (command.Retval keyword: val: (expr.Var left: name:x) ) ] redirects: [] right: ) ) ===== CASE: -n -c func foo(x) { return () } ===== return () ^~~~~~ [ -c flag ]:3: shell functions can't be defined inside proc or func ===== CASE: -n -c func foo(x) { return (named=x) } ===== return (named=x) ^ [ -c flag ]:3: Typed return expects one argument ===== CASE: -n -c func foo(x) { return (x, named=x) } ===== return (x, named=x) ^ [ -c flag ]:3: Typed return doesn't take named arguments ===== CASE: -n -c func foo(x) { return (x, x) } ===== return (x, x) ^ [ -c flag ]:3: Typed return expects one argument OK test-return-args *** Running test-setvar ===== CASE: -n -c proc p(x) { var y = 1 setvar y = 42 } ===== (Proc keyword: name:

sig: (proc_sig.Closed word:(ParamGroup params:[(Param blame_tok: name:x)])) body: (BraceGroup left: children: [ (command.VarDecl keyword: lhs: [(NameType left: name:y)] rhs: (expr.Const c: val:(value.Int i:1)) ) (command.Mutation keyword: lhs: [(N Id.Expr_Name y)] op: rhs: (expr.Const c: val:(value.Int i:42)) ) ] 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: setvar couldn't find matching 'var L' (OILS-ERR-10) ===== CASE: -n -c proc p(x) { var y = 1 setvar L[0] = "L" # ERROR: not declared } ===== setvar L[0] = "L" # ERROR: not declared ^ [ -c flag ]:4: setvar couldn't find matching 'var L' (OILS-ERR-10) ===== CASE: -n -c proc p(x) { var y = 1 setvar d.key = "v" # ERROR: not declared } ===== setvar d.key = "v" # ERROR: not declared ^ [ -c flag ]:4: setvar couldn't find matching 'var d' (OILS-ERR-10) ===== CASE: -n -c proc p(x) { setvar x = "X" # is mutating params allowed? I guess why not. } ===== (Proc keyword: name:

sig: (proc_sig.Closed word:(ParamGroup params:[(Param blame_tok: name:x)])) body: (BraceGroup left: children: [ (command.Mutation keyword: lhs: [(N Id.Expr_Name x)] op: rhs: (DQ ) ) ] redirects: [] right: ) ) OK test-setvar *** Running test-sh-assign ===== CASE: -n -c x=y ===== (command.ShAssignment left: children: [ (command.Sentence child: (command.ShAssignment left: ) ) ===== CASE: -n -c func f() { x=y; } ===== func f() { x=y; } ^~ [ -c flag ]:1: Use var/setvar to assign in YSH ===== CASE: -n -c proc p { x=y; } ===== proc p { x=y; } ^~ [ -c flag ]:1: Use var/setvar to assign in YSH ===== CASE: -n -c { x=y; } ===== (BraceGroup left: children: [ (command.Sentence child: (command.ShAssignment left: ) ===== CASE: -n -c ( x=y; ) ===== (command.Subshell left: child: (command.Sentence child: (command.ShAssignment left: tokens: [] right: ) } ] redirects: [] do_fork: T ) terminator: ) ===== CASE: -n -c echo u'hi' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [] right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c (echo u'hi') ===== (command.Subshell left: child: (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [] right: ) } ] redirects: [] do_fork: T ) right: redirects: [] ) ===== CASE: -n -c echo b'hi'trailing ===== echo b'hi'trailing ^~~~~~~~ [ -c flag ]:1: Unexpected token after YSH single-quoted string ===== CASE: -n -c echo b'hi'#notcomment ===== echo b'hi'#notcomment ^ [ -c flag ]:1: Unexpected token after YSH single-quoted string ===== CASE: -n -c echo 'hi'#notcomment ===== (command.Simple blame_tok: more_env: [] words: [{} {(SQ ) }] redirects: [] do_fork: T ) OK test-string-literals *** Running test-type-expr ===== CASE: -n -c var x: Int = f() ===== (command.VarDecl keyword: lhs: [(NameType left: name:x typ:(TypeExpr tok: name:Int))] rhs: (expr.FuncCall func: (expr.Var left: name:f) args: (ArgList left: pos_args:[] named_args:[] right:) ) ) ===== CASE: -n -c var x Int = f() ===== (command.VarDecl keyword: lhs: [(NameType left: name:x typ:(TypeExpr tok: name:Int))] rhs: (expr.FuncCall func: (expr.Var left: name:f) args: (ArgList left: pos_args:[] named_args:[] right:) ) ) ===== CASE: -n -c proc p (; x Int, y Int; ) { echo hi } ===== (Proc keyword: name:

sig: (proc_sig.Closed positional: (ParamGroup params: [ (Param blame_tok: name: x type: (TypeExpr tok: name:Int) ) (Param blame_tok: name: y type: (TypeExpr tok: name:Int) ) ] ) ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (x Int, y Int; z Int = 0) { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [ (Param blame_tok: name: x type: (TypeExpr tok: name:Int) ) (Param blame_tok: name: y type: (TypeExpr tok: name:Int) ) ] ) named: (ParamGroup params: [ (Param blame_tok: name: z type: (TypeExpr tok: name:Int) default_val: (expr.Const c: val:(value.Int i:0)) ) ] ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) OK test-type-expr *** Running test-units-suffix ===== CASE: -n -c = 100 M M ===== = 100 M M ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_Name) ===== CASE: -n -c = 100 M; echo ===== = 100 M; echo ^ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = 100 Mi; echo ===== = 100 Mi; echo ^~ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = 9.9 Mi; echo ===== = 9.9 Mi; echo ^~ [ -c flag ]:1: unix suffix implemented ===== CASE: -n -c = 9.9e-1 Mi; echo ===== = 9.9e-1 Mi; echo ^~ [ -c flag ]:1: unix suffix implemented ===== CASE: -n -c = 100Mi ===== = 100Mi ^~ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = [100 Mi, 200 Mi] ===== = [100 Mi, 200 Mi] ^~ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = {[42 Ki]: 43 Ki} ===== = {[42 Ki]: 43 Ki} ^~ [ -c flag ]:1: Units suffix not implemented OK test-units-suffix *** Running test-var-decl ===== 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(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 left: name:x)] rhs: (expr.Const c: val:(value.Int i:1)) ) (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 left: name:x)] rhs: (expr.Const c: val:(value.Int i:2)) ) ] redirects: [] right: ) ) (Proc keyword: name: sig: ...0x7f56648cf450 body: (BraceGroup left: children: [ (command.VarDecl keyword: lhs: [(NameType left: name:x)] rhs: (expr.Const c: val:(value.Int i:3)) ) ] redirects: [] right: ) ) ] ) OK test-var-decl *** Running test-ysh-case ===== CASE: -n -c case (x) { (else) { = 1; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var left: name:x)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Sentence child: (command.Expr keyword: ) ] arms_end: redirects: [] ) ===== CASE: -n -c var myexpr = ^[123] case (123) { (myexpr) { echo 1 } } ===== (command.CommandList children: [ (command.VarDecl keyword: lhs: [(NameType left: name:myexpr)] rhs: (expr.Literal inner:(expr.Const c: val:(value.Int i:123))) ) (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Const c: val:(value.Int i:123))) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Var left: name:myexpr)]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {<1>}] 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 left: name:x)) 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 left: name:x)) 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 left: name:x)) 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 left: name:x)) 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: val:(value.Int i:3))) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c: val:(value.Int i:3))]) 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 left: name:x)) 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 left: name:foo)) 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 left: name:foo)) 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 left: name:foo)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (Attribute obj: (expr.Var left: name:obj) op: attr: attr_name: 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 left: name:foo)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c: val:(value.Int i:0))]) 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 left: name:foo)) 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 left: name:foo)) 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 left: name:foo)) 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 left: name:foo)) 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 left: name:foo)) 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 left: name:foo)) 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 left: name:add) args: (ArgList left: pos_args: [ (expr.Const c: val:(value.Int i:10)) (expr.Const c: val:(value.Int i:32)) ] named_args: [] right: ) ) ) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (expr.Binary op: left: (expr.Const c: val:(value.Int i:40)) right: (expr.Const c: val:(value.Int i:2)) ) ] ) 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 left: name:file)) arms_start: arms: [ (CaseArm left: pattern: (Eggex left: regex: (re.Seq children: [ (re.Repeat child: op: (re_repeat.Op op:) ) (SQ <.py>) ] ) flags: [] canonical_flags: "" ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (Eggex left: regex: (re.Seq children: [ (re.Repeat child: op: (re_repeat.Op op:) ) (re.Group child:(re.Alt children:[(SQ <.cc>) (SQ <.h>)])) ] ) flags: [] canonical_flags: "" ) 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 left: name:lang)) 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: [{} { }] 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 left: name:num)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (expr.Const c: val:(value.Int i:1)) (expr.Const c: val:(value.Int i:2)) ] ) 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 left: name:num)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (expr.Const c: val:(value.Int i:1)) (expr.Const c: val:(value.Int i:2)) (expr.Const c: val:(value.Int i:3)) (expr.Const c: val:(value.Int i:4)) (expr.Const c: val:(value.Int i:5)) ] ) 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 left: name:x)) 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: val:(value.Int i:3))]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") 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 left: name:x)) 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: val:(value.Int i:3))]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") 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 left: name:x)) 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: val:(value.Int i:3))]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") 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 left: name:x)) 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: val:(value.Int i:3))]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") 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 left: name:x)) 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: val:(value.Int i:3))]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") 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 left: name:x)) 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: val:(value.Int i:3))]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) OK test-ysh-case *** Running test-ysh-expr ===== CASE: -n -c = 5 mod 3 ===== = 5 mod 3 ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt) ===== CASE: -n -c = >>= ===== = >>= ^~~ [ -c flag ]:1: Syntax error in expression (near Id.Arith_DGreatEqual) ===== CASE: -n -c = %( ===== = %( ^ [ -c flag ]:1: Unexpected token in array literal ===== CASE: -n -c = 42, ===== = 42, ^ [ -c flag ]:1: Invalid trailing comma ===== CASE: -n -c = (42,) ===== = (42,) ^ [ -c flag ]:1: Invalid trailing comma ===== CASE: -n -c =a ===== =a ^ [ -c flag ]:1: =word isn't allowed. Hint: add a space after =, or quote it ===== CASE: -n -c var d = {} = d["foo", "bar"] ===== = d["foo", "bar"] ^ [ -c flag ]:3: Only 1 subscript is accepted OK test-ysh-expr *** Running test-ysh-expr-more ===== CASE: -n -c if (5 == 5) { echo yes } ===== if (5 == 5) { echo yes } ^~ [ -c flag ]:1: Use === to be exact, or ~== to convert types ===== CASE: -n -c echo $[join(x)] ===== (command.Simple blame_tok: more_env: [] words: [ {} { (word_part.ExprSub left: child: (expr.FuncCall func: (expr.Var left: name:join) args: (ArgList left: pos_args: [(expr.Var left: name:x)] named_args: [] right: ) ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo $join(x) ===== echo $join(x) ^ [ -c flag ]:1: Space required before ( ===== CASE: -n -c echo @[split(x)] ===== (command.Simple blame_tok: more_env: [] words: [ {} { (word_part.ExprSub left: child: (expr.FuncCall func: (expr.Var left: name:split) args: (ArgList left: pos_args: [(expr.Var left: name:x)] named_args: [] right: ) ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo @[split(x)] two ===== (command.Simple blame_tok: more_env: [] words: [ {} { (word_part.ExprSub left: child: (expr.FuncCall func: (expr.Var left: name:split) args: (ArgList left: pos_args: [(expr.Var left: name:x)] named_args: [] right: ) ) right: ) } {} ] redirects: [] do_fork: T ) ===== CASE: -n -c echo @[split(x)]extra ===== echo @[split(x)]extra ^~~~~ [ -c flag ]:1: Unexpected token after Expr splice OK test-ysh-expr-more *** Running test-ysh-for ===== CASE: -n -c for x in (obj) { echo $x } ===== (command.ForEach keyword: iter_names: [x] iterable: (for_iter.YshExpr e:(expr.Var left: name:obj) blame:) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {(N 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: [{} {(N 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: [{} {(N 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 left: name:x) blame:) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {(N Id.VSub_DollarName var)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) OK test-ysh-for *** Running test-ysh-nested-proc-func ===== CASE: -n -c proc p { echo 1; proc f { echo f }; echo 2 } ===== proc p { echo 1; proc f { echo f }; echo 2 } ^~~~ [ -c flag ]:1: procs must be defined at the top level ===== CASE: -n -c func f() { echo 1; proc f { echo f }; echo 2 } ===== func f() { echo 1; proc f { echo f }; echo 2 } ^~~~ [ -c flag ]:1: procs must be defined at the top level ===== CASE: -n -c proc p { echo 1; func f() { echo f }; echo 2 } ===== proc p { echo 1; func f() { echo f }; echo 2 } ^~~~ [ -c flag ]:1: funcs must be defined at the top level ===== CASE: -n -c func f() { echo 1; func f2() { echo f }; echo 2 } ===== func f() { echo 1; func f2() { echo f }; echo 2 } ^~~~ [ -c flag ]:1: funcs must be defined at the top level ===== CASE: -n -c proc p { echo 1; +weird() { echo f; }; echo 2 } ===== proc p { echo 1; +weird() { echo f; }; echo 2 } ^ [ -c flag ]:1: shell functions can't be defined inside proc or func ===== CASE: -n -c proc p { echo 1; function f { echo f; }; echo 2 } ===== proc p { echo 1; function f { echo f; }; echo 2 } ^~~~~~~~ [ -c flag ]:1: shell functions can't be defined inside proc or func ===== CASE: -n -c f() { echo 1; proc inner { echo inner; }; echo 2; } ===== f() { echo 1; proc inner { echo inner; }; echo 2; } ^~~~ [ -c flag ]:1: procs must be defined at the top level ===== CASE: -n -c f() { echo 1; g() { echo g; }; echo 2; } ===== (command.ShFunction name_tok: name: f body: (BraceGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {<1>}] redirects: [] do_fork: T ) terminator: ) (command.Sentence child: (command.ShFunction name_tok: name: g body: (BraceGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] redirects: [] right: ) ) terminator: ) (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {<2>}] redirects: [] do_fork: T ) terminator: ) ] redirects: [] right: ) ) ===== CASE: -n -c proc p() { shopt --unset errexit { false hi } } ===== (Proc keyword: name:

sig: (proc_sig.Closed) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {<--unset>} {}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: <"false"> more_env: [] words: [{<"false">} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [ (SourceLine line_num: 1 content: "proc p() { shopt --unset errexit { false hi } }" src: (source__CFlag) ) ] ) do_fork: T ) ] redirects: [] right: ) ) OK test-ysh-nested-proc-func *** Running test-ysh-var ===== CASE: -n -c var x = 1 + ===== var x = 1 + ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c var x = * ===== var x = * ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Star) ===== CASE: -n -c var x = @($(cat < lhs: [(NameType left: name:x)] rhs: (CommandSub left_token: child: (command.Sentence child: (command.VarDecl keyword: lhs: [(NameType left: name:x)] rhs: (expr.Const c: val:(value.Int i:1)) ) terminator: ) right: ) ) ===== CASE: -n -c var x = $(var x = 1 ) ===== (command.VarDecl keyword: lhs: [(NameType left: name:x)] rhs: (CommandSub left_token: child: (command.VarDecl keyword: lhs: [(NameType left: name:x)] rhs: (expr.Const c: val:(value.Int i:1)) ) right: ) ) ===== CASE: -n -c var x = $(var x = 1) ===== var x = $(var x = 1) ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_RParen) ===== CASE: -n -c var x = $(var x = 1; )) ===== var x = $(var x = 1; )) ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_RParen) ===== CASE: -n -c var x = $(var x = 1; ) ) ===== var x = $(var x = 1; ) ) ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_RParen) OK test-ysh-var *** Running test-ysh_bare_words ===== CASE: -n -c echo \$ ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:"$")}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \z ===== echo \z ^~ [ -c flag ]:1: Invalid char escape in unquoted word (OILS-ERR-13) OK test-ysh_bare_words *** Running test-ysh_c_strings ===== CASE: -n -c echo $'\u03bc' ===== (command.Simple blame_tok: (Token id: Id.Lit_Chars col: 0 length: 4 span_id: 0 line: (SourceLine line_num:1 content:"echo $'\\u03bc'" src:(source.CFlag)) tval: echo ) more_env: [] words: [ (CompoundWord parts:[...0x1402]) (CompoundWord parts: [ (SingleQuoted left: (Token id: Id.Left_DollarSingleQuote col: 5 length: 2 span_id: 2 line: ...0x140a tval: "$'" ) tokens: [(Token id:Id.Char_Unicode4 col:7 length:6 span_id:3 line:...0x140a tval:"\\u03bc")] right: (Token id:Id.Right_SingleQuote col:13 length:1 span_id:4 line:...0x140a tval:"'") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: -n -c echo $'\u{03bc}' ===== echo $'\u{03bc}' ^ [ -c flag ]:1: Invalid char escape in C-style string literal (OILS-ERR-11) ===== CASE: -n -c echo $'\u{03bc' ===== echo $'\u{03bc' ^ [ -c flag ]:1: Invalid char escape in C-style string literal (OILS-ERR-11) ===== CASE: -n -c const bad = $'\u{03bc' ===== const bad = $'\u{03bc' ^ [ -c flag ]:1: Invalid char escape in C-style string literal (OILS-ERR-11) ===== 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:[...0x1402]) (CompoundWord parts: [ (SingleQuoted left: (Token id: Id.Left_DollarSingleQuote col: 5 length: 2 span_id: 2 line: ...0x140a tval: "$'" ) tokens: [ (Token id: Id.Unknown_Backslash col: 7 length: 1 span_id: 3 line: ...0x140a tval: "\\" ) (Token id:Id.Char_Literals col:8 length:1 span_id:4 line:...0x140a tval:z) ] right: (Token id:Id.Right_SingleQuote col:9 length:1 span_id:5 line:...0x140a tval:"'") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: -n -c echo $'\z' ===== echo $'\z' ^ [ -c flag ]:1: Invalid char escape in C-style string literal (OILS-ERR-11) ===== CASE: -n -c const bad = $'\z' ===== const bad = $'\z' ^ [ -c flag ]:1: Invalid char escape in C-style string literal (OILS-ERR-11) ===== 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:[...0x1402]) (CompoundWord parts: [ (SingleQuoted left: (Token id: Id.Left_DollarSingleQuote col: 5 length: 2 span_id: 2 line: ...0x140a tval: "$'" ) tokens: [(Token id:Id.Char_Octal3 col:7 length:4 span_id:3 line:...0x140a tval:"\\101")] right: (Token id:Id.Right_SingleQuote col:11 length:1 span_id:4 line:...0x140a 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) OK test-ysh_c_strings *** Running test-ysh_dq_strings ===== 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:[...0x1402]) (CompoundWord parts: [ (DoubleQuoted left: (Token id:Id.Left_DoubleQuote col:5 length:1 span_id:2 line:...0x140a tval:"\"") parts: [ (Token id: Id.Lit_BadBackslash col: 6 length: 1 span_id: 3 line: ...0x140a tval: "\\" ) (Token id:Id.Lit_Chars col:7 length:1 span_id:4 line:...0x140a tval:z) ] right: (Token id:Id.Right_DoubleQuote col:8 length:1 span_id:5 line:...0x140a tval:"\"") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: +O parse_backslash -n -c echo test-parse_backslash "\z" ===== echo test-parse_backslash "\z" ^ [ -c flag ]:1: Invalid char escape in double quoted string (OILS-ERR-12) ===== CASE: -n -c echo "\z" ===== echo "\z" ^ [ -c flag ]:1: Invalid char escape in double quoted string (OILS-ERR-12) ===== CASE: -n -c const bad = "\z" ===== const bad = "\z" ^ [ -c flag ]:1: Invalid char escape in double quoted string (OILS-ERR-12) ===== 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:[...0x1402]) (CompoundWord parts: [ (DoubleQuoted left: (Token id:Id.Left_DoubleQuote col:5 length:1 span_id:2 line:...0x140a tval:"\"") parts: [ (Token id: Id.Lit_BadBackslash col: 6 length: 1 span_id: 3 line: ...0x140a tval: "\\" ) (Token id:Id.Lit_Chars col:7 length:5 span_id:4 line:...0x140a tval:u1234) ] right: (Token id:Id.Right_DoubleQuote col:12 length:1 span_id:5 line:...0x140a tval:"\"") ) ] ) ] redirects: [] do_fork: T ) ===== CASE: -n -c echo "\u1234" ===== echo "\u1234" ^ [ -c flag ]:1: Invalid char escape in double quoted string (OILS-ERR-12) ===== CASE: -n -c const bad = "\u1234" ===== const bad = "\u1234" ^ [ -c flag ]:1: Invalid char escape in double quoted string (OILS-ERR-12) ===== 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:[...0x1402]) (CompoundWord parts: [ (DoubleQuoted left: (Token id:Id.Left_DoubleQuote col:5 length:1 span_id:2 line:...0x140a tval:"\"") parts: [ (CommandSub left_token: (Token id: Id.Left_Backtick col: 6 length: 1 span_id: 3 line: ...0x140a 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: ...0x13e2 right_token: (Token id: Id.Backtick_Right col: 14 length: 1 span_id: 5 line: ...0x140a tval: "`" ) ) ) tval: echo ) more_env: [] words: [ (CompoundWord parts:[...0x13b2]) (CompoundWord parts: [(Token id:Id.Lit_Chars col:5 length:2 span_id:8 line:...0x13b6 tval:hi)] ) ] redirects: [] do_fork: T ) right: ...0x13d6 ) ] right: (Token id:Id.Right_DoubleQuote col:15 length:1 span_id:10 line:...0x140a 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 (OILS-ERR-12) OK test-ysh_dq_strings test/ysh-parse-errors.sh: 49 tests passed.