*** Running test-parse-osh --- (command.CommandList children: [ (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [ {<Id.Lit_Chars echo>} { (SingleQuoted left: <Id.Left_DollarSingleQuote "$'"> sval: "one\ntwo" right: <Id.Right_SingleQuote "'"> ) } ] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name a> name:a typ:(TypeExpr tok:<Id.Expr_Name Int> name:Int))] rhs: (expr.Binary op: <Id.Arith_Plus "+"> left: (expr.Const c:<Id.Expr_DecInt 1> val:(value.Int i:1)) right: (expr.Binary op: <Id.Arith_Star "*"> left: (expr.Const c:<Id.Expr_DecInt 2> val:(value.Int i:2)) right: (expr.Const c:<Id.Expr_DecInt 3> val:(value.Int i:3)) ) ) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_VarLike "a="> ($ a)}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name b> name:b typ:(TypeExpr tok:<Id.Expr_Name Float> name:Float))] rhs: (expr.Binary op: <Id.Arith_Slash /> left: (expr.Const c:<Id.Expr_DecInt 5> val:(value.Int i:5)) right: (expr.Const c:<Id.Expr_DecInt 6> val:(value.Int i:6)) ) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_VarLike "b="> ($ b)}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_Chars hi>}] do_fork: T ) (command.CommandList children: [ (command.Sentence child: (command.Mutation keyword: <Id.KW_SetVar setvar> lhs: [<Id.Expr_Name a>] op: <Id.Arith_Equal "="> rhs: (expr.Var left:<Id.Expr_Name b> name:b) ) terminator: <Id.Op_Semi ";"> ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_Chars hi>}] do_fork: T ) ] ) (command.Mutation keyword: <Id.KW_SetVar setvar> lhs: [<Id.Expr_Name x>] op: <Id.Arith_Equal "="> rhs: (expr.Const c:<Id.Expr_DecInt 4> val:(value.Int i:4)) ) (command.Mutation keyword: <Id.KW_SetVar setvar> lhs: [<Id.Expr_Name d>] op: <Id.Arith_Equal "="> rhs: (expr.Const c:<Id.Expr_DecInt 1> val:(value.Int i:1)) ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name y> name:y)] rhs: (expr.Var left:<Id.Expr_Name a> name:a) ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name z> name:z)] rhs: (expr.Var left:<Id.Expr_Name b> name:b) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_Chars hi>}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name mycmd> name:mycmd)] rhs: (expr.Binary op: <Id.Arith_Plus "+"> left: (CommandSub left_token: <Id.Left_DollarParen "$("> child: (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_Chars cmd>}] do_fork: T ) right: <Id.Eof_RParen ")"> ) right: (DQ (CommandSub left_token: <Id.Left_DollarParen "$("> child: (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_Chars cmd>}] do_fork: T ) right: <Id.Eof_RParen ")"> ) ) ) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_VarLike "mycmd="> ($ mycmd)}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name mybrace> name:mybrace)] rhs: (expr.Binary op:<Id.Arith_Plus "+"> left:(${ Id.VSub_Name b) right:(DQ (${ Id.VSub_Name b))) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_VarLike "mybrace="> ($ mybrace)}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name paren> name:paren)] rhs: (expr.Binary op: <Id.Arith_Star "*"> left: (expr.Binary op: <Id.Arith_Plus "+"> left: (expr.Const c:<Id.Expr_DecInt 1> val:(value.Int i:1)) right: (expr.Const c:<Id.Expr_DecInt 2> val:(value.Int i:2)) ) right: (expr.Const c:<Id.Expr_DecInt 3> val:(value.Int i:3)) ) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_VarLike "paren="> ($ paren)}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name line_cont> name:line_cont)] rhs: (expr.Binary op: <Id.Arith_Plus "+"> left: (expr.Const c:<Id.Expr_DecInt 4> val:(value.Int i:4)) right: (expr.Const c:<Id.Expr_DecInt 5> val:(value.Int i:5)) ) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_VarLike "line_cont="> ($ line_cont)}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name multiline> name:multiline)] rhs: (expr.Binary op: <Id.Arith_Plus "+"> left: (expr.Const c:<Id.Expr_DecInt 6> val:(value.Int i:6)) right: (expr.Const c:<Id.Expr_DecInt 7> val:(value.Int i:7)) ) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_VarLike "multiline="> ($ multiline)}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name aug> name:aug)] rhs: (expr.Const c:<Id.Expr_DecInt 8> val:(value.Int i:8)) ) (command.Mutation keyword: <Id.KW_SetVar setvar> lhs: [<Id.Expr_Name aug>] op: <Id.Arith_PlusEqual "+="> rhs: (expr.Const c:<Id.Expr_DecInt 9> val:(value.Int i:9)) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {<Id.Lit_VarLike "aug="> ($ aug)}] do_fork: T ) ] ) --- (command.CommandList children: [ (command.Simple blame_tok: <Id.Lit_Chars shopt> more_env: [] words: [ {<Id.Lit_Chars shopt>} {<Id.Lit_Chars -s>} {<Id.Lit_Chars oil-parse-at>} {<Id.Lit_Chars static-word-eval>} ] do_fork: T ) (command.ShAssignment left: <Id.Lit_VarLike "myglobal="> pairs: [ (AssignPair left: <Id.Lit_VarLike "myglobal="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "myglobal="> name:myglobal) op: assign_op.Equal rhs: {<Id.Lit_Chars global>} ) ] ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name myarray> name:myarray)] rhs: (ShArrayLiteral left: <Id.Left_ColonPipe ":|"> words: [ {($ myglobal)} { (SingleQuoted left: <Id.Left_DollarSingleQuote "$'"> sval: "line\n" right: <Id.Right_SingleQuote "'"> ) } { (BracedVarSub left: <Id.Left_DollarBrace "${"> token: <Id.VSub_Name z> var_name: z suffix_op: (suffix_op.Unary op: <Id.VTest_ColonHyphen ":-"> arg_word: {<Id.Lit_Chars default>} ) right: <Id.Right_DollarBrace "}"> ) } ] right: <Id.Op_Pipe "|"> ) ) (command.Simple blame_tok: <Id.Lit_Chars spec> more_env: [] words: [ {<Id.Lit_Chars spec> <Id.Lit_Slash /> <Id.Lit_Chars bin> <Id.Lit_Slash /> <Id.Lit_Chars argv.py>} {<Id.Lit_Splice "@myarray">} ] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [ {<Id.Lit_Chars echo>} {<Id.Lit_VarLike "len="> (word_part.ExprSub left: <Id.Left_DollarBracket "$["> child: (expr.FuncCall func: (expr.Var left:<Id.Expr_Name len> name:len) args: (ArgList left: <Id.Op_LParen "("> pos_args: [(expr.Var left:<Id.Expr_Name myarray> name:myarray)] named_args: [] right: <Id.Op_RParen ")"> ) ) right: <Id.Op_RBracket "]"> ) } ] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars append> more_env: [] words: [ {<Id.Lit_Chars append>} {<Id.Lit_Chars _>} {(SQ "1 2")} { (BracedVarSub left: <Id.Left_DollarBrace "${"> token: <Id.VSub_Name myglobal> var_name: myglobal suffix_op: (suffix_op.Unary op: <Id.VTest_ColonHyphen ":-"> arg_word: {<Id.Lit_Chars default>} ) right: <Id.Right_DollarBrace "}"> ) } ] typed_args: (ArgList left: <Id.Op_LParen "("> pos_args: [(expr.Var left:<Id.Expr_Name myarray> name:myarray)] named_args: [] right: <Id.Op_RParen ")"> ) do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars spec> more_env: [] words: [ {<Id.Lit_Chars spec> <Id.Lit_Slash /> <Id.Lit_Chars bin> <Id.Lit_Slash /> <Id.Lit_Chars argv.py>} {<Id.Lit_Splice "@myarray">} ] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [ {<Id.Lit_Chars echo>} {<Id.Lit_VarLike "len="> (word_part.ExprSub left: <Id.Left_DollarBracket "$["> child: (expr.FuncCall func: (expr.Var left:<Id.Expr_Name len> name:len) args: (ArgList left: <Id.Op_LParen "("> pos_args: [(expr.Var left:<Id.Expr_Name myarray> name:myarray)] named_args: [] right: <Id.Op_RParen ")"> ) ) right: <Id.Op_RBracket "]"> ) } ] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>}] do_fork: T ) (command.ForEach keyword: <Id.KW_For for> iter_names: [item] iterable: (for_iter.YshExpr e: (expr.Var left:<Id.Expr_Name myarray> name:myarray) blame: <Id.KW_In in> ) body: (BraceGroup left: <Id.Lit_LBrace "{"> children: [ (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {(DQ <Id.Lit_Chars " "> ($ item))}] do_fork: T ) ] right: <Id.Lit_RBrace "}"> ) ) ] ) --- (command.CommandList children: [ (command.ShAssignment left: <Id.Lit_VarLike "global_var="> pairs: [ (AssignPair left: <Id.Lit_VarLike "global_var="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "global_var="> name:global_var) op: assign_op.Equal rhs: {<Id.Lit_Chars global>} ) ] ) (command.ShFunction name_tok: <Id.Lit_Chars g> name: g body: (BraceGroup left: <Id.Lit_LBrace "{"> children: [ (command.Simple blame_tok: <Id.Lit_Chars local> more_env: [] words: [{<Id.Lit_Chars local>} {<Id.Lit_VarLike "g_var="> <Id.Lit_Chars f>}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {($ g_var)}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {($ f_var)}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name oil_var> name:oil_var)] rhs: (expr.Var left:<Id.Expr_Name global_var> name:global_var) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {($ oil_var)}] do_fork: T ) ] right: <Id.Lit_RBrace "}"> ) ) (command.ShFunction name_tok: <Id.Lit_Chars f> name: f body: (BraceGroup left: <Id.Lit_LBrace "{"> children: [ (command.Simple blame_tok: <Id.Lit_Chars local> more_env: [] words: [{<Id.Lit_Chars local>} {<Id.Lit_VarLike "f_var="> <Id.Lit_Chars f>}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {($ f_var)}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars g> more_env: [] words: [{<Id.Lit_Chars g>}] do_fork: T ) ] right: <Id.Lit_RBrace "}"> ) ) (command.Simple blame_tok:<Id.Lit_Chars f> more_env:[] words:[{<Id.Lit_Chars f>}] do_fork:T) ] ) --- (command.CommandList children: [ (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {(SQ "This is a shell script with OSH extensions!")}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name x> name:x)] rhs: (expr.Binary op: <Id.Arith_Plus "+"> left: (expr.Const c:<Id.Expr_DecInt 1> val:(value.Int i:1)) right: (expr.Binary op: <Id.Arith_Star "*"> left: (expr.Const c:<Id.Expr_DecInt 2> val:(value.Int i:2)) right: (expr.Const c:<Id.Expr_DecInt 3> val:(value.Int i:3)) ) ) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {(DQ <Id.Lit_Chars "x: "> ($ x))}] do_fork: T ) (command.Mutation keyword: <Id.KW_SetVar setvar> lhs: [<Id.Expr_Name x>] op: <Id.Arith_PlusEqual "+="> rhs: (expr.Const c:<Id.Expr_DecInt 1> val:(value.Int i:1)) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {(DQ <Id.Lit_Chars "x: "> ($ x))}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name mylist> name:mylist)] rhs: (expr.List left: <Id.Op_LBracket "["> elts: [ (expr.Const c:<Id.Expr_DecInt 1> val:(value.Int i:1)) (expr.Const c:<Id.Expr_DecInt 2> val:(value.Int i:2)) (expr.Const c:<Id.Expr_DecInt 3> val:(value.Int i:3)) ] ctx: expr_context.Store ) ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name y> name:y)] rhs: (expr.Binary op: <Id.Arith_Star "*"> left: (Subscript left: <Id.Op_LBracket "["> obj: (expr.Var left:<Id.Expr_Name mylist> name:mylist) index: (expr.Const c:<Id.Expr_DecInt 1> val:(value.Int i:1)) ) right: (expr.Const c:<Id.Expr_DecInt 10> val:(value.Int i:10)) ) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {(DQ <Id.Lit_Chars "y: "> ($ y))}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name list2> name:list2)] rhs: (expr.Binary op: <Id.Arith_DPlus "++"> left: (expr.Var left:<Id.Expr_Name mylist> name:mylist) right: (expr.List left: <Id.Op_LBracket "["> elts: [ (expr.Const c:<Id.Expr_DecInt 4> val:(value.Int i:4)) (expr.Const c:<Id.Expr_DecInt 5> val:(value.Int i:5)) ] ctx: expr_context.Store ) ) ) (command.Simple blame_tok: <Id.Lit_Chars pp> more_env: [] words: [{<Id.Lit_Chars pp>} {<Id.Lit_Chars cell>} {<Id.Lit_Chars list2>}] do_fork: T ) (command.ShAssignment left: <Id.Lit_VarLike "str1="> pairs: [ (AssignPair left: <Id.Lit_VarLike "str1="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "str1="> name:str1) op: assign_op.Equal rhs: {(SQ "shell string")} ) ] ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name str2> name:str2)] rhs: (DQ <Id.Lit_Chars "Oil string">) ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name str3> name:str3)] rhs: (expr.Binary op: <Id.Arith_DPlus "++"> left: (expr.Var left:<Id.Expr_Name str1> name:str1) right: (expr.Var left:<Id.Expr_Name str2> name:str2) ) ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {(DQ <Id.Lit_Chars "str3 = "> ($ str3))}] do_fork: T ) ] ) --- (command.CommandList children: [ (command.ShFunction name_tok: <Id.Lit_Chars argv> name: argv body: (BraceGroup left: <Id.Lit_LBrace "{"> children: [ (command.Simple blame_tok: <Id.Lit_Chars python> more_env: [] words: [ {<Id.Lit_Chars python>} {<Id.Lit_Chars -c>} {(SQ "import sys;print(sys.argv[1:])")} {<Id.Lit_Splice "@ARGV">} ] do_fork: T ) ] right: <Id.Lit_RBrace "}"> ) ) (command.ShFunction name_tok: <Id.Lit_Chars show> name: show body: (BraceGroup left: <Id.Lit_LBrace "{"> children: [ (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>} {(SQ "=====")}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars argv> more_env: [] words: [{<Id.Lit_Chars argv>} {<Id.Lit_Splice "@ARGV">}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [{<Id.Lit_Chars echo>}] do_fork: T ) ] right: <Id.Lit_RBrace "}"> ) ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name strarray> name:strarray)] rhs: (ShArrayLiteral left: <Id.Left_PercentParen "%("> words: [ {<Id.Lit_Chars bare>} {<Id.Lit_Chars words>} {<Id.Lit_Star "*"> <Id.Lit_Chars .sh>} (word.BracedTree parts: [ (word_part.BracedTuple words:[{<Id.Lit_Chars a>} {<Id.Lit_Chars b>}]) <Id.Lit_Splice "@example"> <Id.Lit_Chars .com> ] ) {(SQ sq)} { (DQ <Id.Lit_Chars "dq "> (BracedVarSub left: <Id.Left_DollarBrace "${"> token: <Id.VSub_Name x> var_name: x suffix_op: (suffix_op.Unary op: <Id.VTest_ColonHyphen ":-"> arg_word: {<Id.Lit_Chars default>} ) right: <Id.Right_DollarBrace "}"> ) ) } ] right: <Id.Right_ShArrayLiteral ")"> ) ) (command.Simple blame_tok: <Id.Lit_Chars show> more_env: [] words: [{<Id.Lit_Chars show>} {<Id.Lit_Splice "@strarray">}] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name cmd_sub> name:cmd_sub)] rhs: (CommandSub left_token: <Id.Left_DollarParen "$("> child: (command.Simple blame_tok: <Id.Lit_Chars echo> more_env: [] words: [ {<Id.Lit_Chars echo>} {<Id.Lit_Chars bare>} {<Id.Lit_Chars words>} {<Id.Lit_Star "*"> <Id.Lit_Chars .sh>} (word.BracedTree parts: [ (word_part.BracedTuple words: [{<Id.Lit_Chars a>} {<Id.Lit_Chars b>}] ) <Id.Lit_Splice "@example"> <Id.Lit_Chars .com> ] ) {(SQ sq)} { (DQ <Id.Lit_Chars "dq "> (BracedVarSub left: <Id.Left_DollarBrace "${"> token: <Id.VSub_Name x> var_name: x suffix_op: (suffix_op.Unary op: <Id.VTest_ColonHyphen ":-"> arg_word: {<Id.Lit_Chars default>} ) right: <Id.Right_DollarBrace "}"> ) ) } ] do_fork: T ) right: <Id.Eof_RParen ")"> ) ) (command.Simple blame_tok: <Id.Lit_Chars show> more_env: [] words: [{<Id.Lit_Chars show>} {($ cmd_sub)}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars show> more_env: [] words: [ {<Id.Lit_Chars show>} { (word_part.ExprSub left: <Id.Left_DollarBracket "$["> child: (expr.Binary op: <Id.Arith_DPlus "++"> left: (expr.Binary op:<Id.Arith_DPlus "++"> left:(SQ "quoted ") right:(SQ "words ")) right: (DQ <Id.Lit_Chars "dq "> (BracedVarSub left: <Id.Left_DollarBrace "${"> token: <Id.VSub_Name x> var_name: x suffix_op: (suffix_op.Unary op: <Id.VTest_ColonHyphen ":-"> arg_word: {<Id.Lit_Chars default>} ) right: <Id.Right_DollarBrace "}"> ) ) ) right: <Id.Op_RBracket "]"> ) } ] do_fork: T ) ] ) --- (command.CommandList children: [ (command.ShFunction name_tok: <Id.Lit_Chars argv> name: argv body: (BraceGroup left: <Id.Lit_LBrace "{"> children: [ (command.Sentence child: (command.Simple blame_tok: <Id.Lit_Chars spec> more_env: [] words: [ {<Id.Lit_Chars spec> <Id.Lit_Slash /> <Id.Lit_Chars bin> <Id.Lit_Slash /> <Id.Lit_Chars argv.py> } {(DQ ($ Id.VSub_At))} ] do_fork: T ) terminator: <Id.Op_Semi ";"> ) ] right: <Id.Lit_RBrace "}"> ) ) (command.ShAssignment left: <Id.Lit_VarLike "CONFIG_HAVE_FOO="> pairs: [ (AssignPair left: <Id.Lit_VarLike "CONFIG_HAVE_FOO="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "CONFIG_HAVE_FOO="> name:CONFIG_HAVE_FOO) op: assign_op.Equal rhs: {<Id.Lit_Chars yes>} ) ] ) (command.ShAssignment left: <Id.Lit_VarLike "path="> pairs: [ (AssignPair left: <Id.Lit_VarLike "path="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "path="> name:path) op: assign_op.Equal rhs: {(SQ "/etc/path with spaces")} ) ] ) (command.ShAssignment left: <Id.Lit_VarLike "flags="> pairs: [ (AssignPair left: <Id.Lit_VarLike "flags="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "flags="> name:flags) op: assign_op.Equal rhs: {(SQ "")} ) ] ) (command.If if_kw: <Id.KW_If if> arms: [ (IfArm keyword: <Id.KW_If if> cond: (condition.Shell commands: [ (command.Sentence child: (command.Simple blame_tok: <Id.Lit_LBracket "["> more_env: [] words: [ {<Id.Lit_LBracket "[">} {<Id.Lit_Chars -n>} {(DQ (${ Id.VSub_Name CONFIG_HAVE_FOO))} {<Id.Lit_RBracket "]">} ] do_fork: T ) terminator: <Id.Op_Semi ";"> ) ] ) then_kw: <Id.KW_Then then> action: [ (command.ShAssignment left: <Id.Lit_VarLike "flags="> pairs: [ (AssignPair left: <Id.Lit_VarLike "flags="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "flags="> name:flags) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Name flags) <Id.Lit_Chars " --foo="> ($ path))} ) ] ) ] then_tok: <Id.KW_Then then> ) ] else_action: [] fi_kw: <Id.KW_Fi fi> ) (command.If if_kw: <Id.KW_If if> arms: [ (IfArm keyword: <Id.KW_If if> cond: (condition.Shell commands: [ (command.Sentence child: (command.Simple blame_tok: <Id.Lit_LBracket "["> more_env: [] words: [ {<Id.Lit_LBracket "[">} {<Id.Lit_Chars -n>} {(DQ (${ Id.VSub_Name CONFIG_HAVE_BAR))} {<Id.Lit_RBracket "]">} ] do_fork: T ) terminator: <Id.Op_Semi ";"> ) ] ) then_kw: <Id.KW_Then then> action: [ (command.ShAssignment left: <Id.Lit_VarLike "flags="> pairs: [ (AssignPair left: <Id.Lit_VarLike "flags="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "flags="> name:flags) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Name flags) <Id.Lit_Chars " --bar">)} ) ] ) ] then_tok: <Id.KW_Then then> ) ] else_action: [] fi_kw: <Id.KW_Fi fi> ) (command.Simple blame_tok: <Id.Lit_Chars argv> more_env: [] words: [{<Id.Lit_Chars argv>} {(${ Id.VSub_Name flags)}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars set> more_env: [] words: [{<Id.Lit_Chars set>} {<Id.Lit_Chars -o>} {<Id.Lit_Chars errexit>}] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars shopt> more_env: [] words: [ {<Id.Lit_Chars shopt>} {<Id.Lit_Chars -s>} {<Id.Lit_Chars parse_at>} {<Id.Lit_Chars simple_word_eval>} ] do_fork: T ) (command.Mutation keyword: <Id.KW_SetVar setvar> lhs: [<Id.Expr_Name CONFIG_HAVE_FOO>] op: <Id.Arith_Equal "="> rhs: (DQ <Id.Lit_Chars yes>) ) (command.Mutation keyword: <Id.KW_SetVar setvar> lhs: [<Id.Expr_Name path>] op: <Id.Arith_Equal "="> rhs: (DQ <Id.Lit_Chars "/etc/path with spaces">) ) (command.Mutation keyword: <Id.KW_SetVar setvar> lhs: [<Id.Expr_Name flags>] op: <Id.Arith_Equal "="> rhs: (ShArrayLiteral left: <Id.Left_PercentParen "%("> words: [] right: <Id.Right_ShArrayLiteral ")"> ) ) (command.If if_kw: <Id.KW_If if> arms: [ (IfArm keyword: <Id.KW_If if> cond: (condition.Shell commands: [ (command.Sentence child: (command.Simple blame_tok: <Id.Lit_Chars test> more_env: [] words: [{<Id.Lit_Chars test>} {<Id.Lit_Chars -n>} {($ CONFIG_HAVE_FOO)}] do_fork: T ) terminator: <Id.Op_Semi ";"> ) ] ) then_kw: <Id.KW_Then then> action: [ (command.Simple blame_tok: <Id.Lit_Chars append> more_env: [] words: [ {<Id.Lit_Chars append>} {<Id.Lit_Chars -->} {<Id.Lit_Chars --foo> <Id.Lit_Equals "="> ($ path)} ] typed_args: (ArgList left: <Id.Op_LParen "("> pos_args: [(expr.Var left:<Id.Expr_Name flags> name:flags)] named_args: [] right: <Id.Op_RParen ")"> ) do_fork: T ) ] then_tok: <Id.KW_Then then> ) ] else_action: [] fi_kw: <Id.KW_Fi fi> ) (command.If if_kw: <Id.KW_If if> arms: [ (IfArm keyword: <Id.KW_If if> cond: (condition.Shell commands: [ (command.Sentence child: (command.Simple blame_tok: <Id.Lit_Chars test> more_env: [] words: [{<Id.Lit_Chars test>} {<Id.Lit_Chars -n>} {($ CONFIG_HAVE_BAR)}] do_fork: T ) terminator: <Id.Op_Semi ";"> ) ] ) then_kw: <Id.KW_Then then> action: [ (command.Simple blame_tok: <Id.Lit_Chars append> more_env: [] words: [{<Id.Lit_Chars append>} {<Id.Lit_Chars -->} {<Id.Lit_Chars --bar>}] typed_args: (ArgList left: <Id.Op_LParen "("> pos_args: [(expr.Var left:<Id.Expr_Name flags> name:flags)] named_args: [] right: <Id.Op_RParen ")"> ) do_fork: T ) ] then_tok: <Id.KW_Then then> ) ] else_action: [] fi_kw: <Id.KW_Fi fi> ) (command.Simple blame_tok: <Id.Lit_Chars argv> more_env: [] words: [{<Id.Lit_Chars argv>} {<Id.Lit_Splice "@flags">}] do_fork: T ) ] ) --- (command.CommandList children: [ (command.ShFunction name_tok: <Id.Lit_Chars argv> name: argv body: (BraceGroup left: <Id.Lit_LBrace "{"> children: [ (command.Sentence child: (command.Simple blame_tok: <Id.Lit_Chars spec> more_env: [] words: [ {<Id.Lit_Chars spec> <Id.Lit_Slash /> <Id.Lit_Chars bin> <Id.Lit_Slash /> <Id.Lit_Chars argv.py> } {(DQ ($ Id.VSub_At))} ] do_fork: T ) terminator: <Id.Op_Semi ";"> ) ] right: <Id.Lit_RBrace "}"> ) ) (command.ShAssignment left: <Id.Lit_VarLike "regex="> pairs: [ (AssignPair left: <Id.Lit_VarLike "regex="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "regex="> name:regex) op: assign_op.Equal rhs: { (ShArrayLiteral left: <Id.Op_LParen "("> words: [{<Id.Lit_Chars old1>} {<Id.Lit_Chars old2>}] right: <Id.Right_ShArrayLiteral ")"> ) } ) ] ) (command.ShAssignment left: <Id.Lit_VarLike "flags="> pairs: [ (AssignPair left: <Id.Lit_VarLike "flags="> lhs: (sh_lhs.Name left:<Id.Lit_VarLike "flags="> name:flags) op: assign_op.Equal rhs: {(ShArrayLiteral left:<Id.Op_LParen "("> words:[] right:<Id.Right_ShArrayLiteral ")">)} ) ] ) (command.ForEach keyword: <Id.KW_For for> iter_names: [r] iterable: (for_iter.Words words: [ { (DQ (BracedVarSub left: <Id.Left_DollarBrace "${"> token: <Id.VSub_Name regex> var_name: regex bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At) right: <Id.Right_DollarBrace "}"> ) ) } ] ) semi_tok: <Id.Op_Semi ";"> body: (command.DoGroup left: <Id.KW_Do do> children: [ (command.ShAssignment left: <Id.Lit_ArrayLhsOpen "flags["> pairs: [ (AssignPair left: <Id.Lit_ArrayLhsOpen "flags["> lhs: (sh_lhs.IndexedName left: <Id.Lit_ArrayLhsOpen "flags["> name: flags index: { (BracedVarSub left: <Id.Left_DollarBrace "${"> token: <Id.VSub_Name flags> var_name: flags prefix_op: <Id.VSub_Pound "#"> bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At) right: <Id.Right_DollarBrace "}"> ) } ) op: assign_op.Equal rhs: {(DQ <Id.Lit_Chars "--regex="> ($ r))} ) ] ) ] right: <Id.KW_Done done> ) ) (command.Simple blame_tok: <Id.Lit_Chars argv> more_env: [] words: [ {<Id.Lit_Chars argv>} { (DQ (BracedVarSub left: <Id.Left_DollarBrace "${"> token: <Id.VSub_Name flags> var_name: flags bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At) right: <Id.Right_DollarBrace "}"> ) ) } ] do_fork: T ) (command.Simple blame_tok: <Id.Lit_Chars shopt> more_env: [] words: [ {<Id.Lit_Chars shopt>} {<Id.Lit_Chars -s>} {<Id.Lit_Chars simple_word_eval>} {<Id.Lit_Chars parse_at>} ] do_fork: T ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name regex2> name:regex2)] rhs: (ShArrayLiteral left: <Id.Left_PercentParen "%("> words: [{<Id.Lit_Chars new1>} {<Id.Lit_Chars new2>}] right: <Id.Right_ShArrayLiteral ")"> ) ) (command.VarDecl keyword: <Id.KW_Var var> lhs: [(NameType left:<Id.Expr_Name flags2> name:flags2)] rhs: (ShArrayLiteral left: <Id.Left_PercentParen "%("> words: [] right: <Id.Right_ShArrayLiteral ")"> ) ) (command.ForEach keyword: <Id.KW_For for> iter_names: [r] iterable: (for_iter.Words words:[{<Id.Lit_Splice "@regex2">}]) semi_tok: <Id.Op_Semi ";"> body: (command.DoGroup left: <Id.KW_Do do> children: [ (command.Simple blame_tok: <Id.Lit_Chars append> more_env: [] words: [{<Id.Lit_Chars append>} {(DQ <Id.Lit_Chars "--regex="> ($ r))}] typed_args: (ArgList left: <Id.Op_LParen "("> pos_args: [(expr.Var left:<Id.Expr_Name flags2> name:flags2)] named_args: [] right: <Id.Op_RParen ")"> ) do_fork: T ) ] right: <Id.KW_Done done> ) ) (command.Simple blame_tok: <Id.Lit_Chars argv> more_env: [] words: [{<Id.Lit_Chars argv>} {<Id.Lit_Splice "@flags2">}] do_fork: T ) ] ) OK test-parse-osh *** Running test-run-osh ysh/testdata/array-rewrite-1.sh --- ['--regex=old1', '--regex=old2'] append "--regex=$r" (flags2) ^ ysh/testdata/array-rewrite-1.sh:40: 'append' doesn't accept flag -- append "--regex=$r" (flags2) ^ ysh/testdata/array-rewrite-1.sh:40: 'append' doesn't accept flag -- [] ysh/testdata/array-rewrite-2.sh --- ['--foo=/etc/path', 'with', 'spaces'] ['--foo=/etc/path with spaces'] ysh/testdata/sigil-pairs.sh --- ===== ['@ARGV'] ===== ['@ARGV'] ===== ['@ARGV'] ysh/testdata/array-splice-demo.osh --- shopt -s oil-parse-at static-word-eval ^~~~~ ysh/testdata/array-splice-demo.osh:2: 'shopt' got invalid option 'oil-parse-at' ['@myarray'] len=3 ['@myarray'] len=6 global line default _ 1 2 global ysh/testdata/assign.osh skipping ysh/testdata/assign.osh ysh/testdata/hello.osh --- This is a shell script with OSH extensions! x: 7 x: 8 y: 20 pp cell list2 ^~~~ ysh/testdata/hello.osh:26: 'pp' got invalid action 'cell' str3 = shell stringOil string ysh/testdata/no-dynamic-scope.osh skipping ysh/testdata/no-dynamic-scope.osh OK test-run-osh *** Running test-run-ysh --- + Call in expression context: 3 + Inline call that coerces to string: 3 3 + Inline calls can be part of a word: --length=3 33 + Caveat: can't double quote. It would break programs. Should we add an option 'shopt -s parse_dparen'? --length=3 + Just as you can splice @myarray spam eggs ham + You can also splice the result of a function returning a sequence: Notes: - the Dict->reverse() method is from Python. hello world Parts: aaa BB c join(parts): aaaBBc + Another way of doing it, without creating another variable: aaaBBc j => aaa:BB:c When IFS is the default, split(j) => aaa:BB:c When IFS is :, split(j) => aaa BB c + Since there is no word splitting of unquoted $(ls), here is an idiom: bin/ lib/ --- hello 42 --- Hello world! first line second line Some string Some string $myvar Some string Some st Some s 11 DefaultValueIfFooIsMissingOrEmpty --- perhaps it's already here 42 I am just a normal string I am just a normal string and I am just a normal string I am just a normal string_ I am some string \n Hello world! I'm just a string it's true I really do it's true I really do Not a file I'm an abstraction I'm passed hi failure 2024 Here I am! could be anything really date: unrecognized option '--wrong-flag' Try 'date --help' for more information. there was an error number 2024-08-06 2024 OK test-run-ysh ysh/run.sh: 3 tests passed.