(command.CommandList children: [ (command.ShFunction name: argv body: (BraceGroup children: [ (command.Sentence child: (C {<'spec/bin/argv.py'>} {(DQ ($ Id.VSub_At '$@'))}) terminator: ) ] ) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:CONFIG_HAVE_FOO) op: assign_op.Equal rhs: {} spids: [48] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:path) op: assign_op.Equal rhs: {(SQ <'/etc/path with spaces'>)} spids: [51] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:flags) op: assign_op.Equal rhs: {(SQ )} spids: [56] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {} {<-n>} {(DQ (${ Id.VSub_Name CONFIG_HAVE_FOO))} {} ) terminator: ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:flags) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Name flags) <' --foo='> ($ Id.VSub_DollarName '$path'))} spids: [80] ) ] ) ] spids: [62 77] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {} {<-n>} {(DQ (${ Id.VSub_Name CONFIG_HAVE_BAR))} {} ) terminator: ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:flags) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Name flags) <' --bar'>)} spids: [110] ) ] ) ] spids: [92 107] ) ] ) (C {} {(${ Id.VSub_Name flags)}) (C {} {<-o>} {}) (C {} {<-s>} {} {}) (command.PlaceMutation keyword: lhs: [(place_expr.Var name:)] op: rhs: (DQ ) ) (command.PlaceMutation keyword: lhs: [(place_expr.Var name:)] op: rhs: (DQ <'/etc/path with spaces'>) ) (command.PlaceMutation keyword: lhs: [(place_expr.Var name:)] op: rhs: (sh_array_literal left:) ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {} {<-n>} {($ Id.VSub_DollarName '$CONFIG_HAVE_FOO')}) terminator: ) ] ) action: [ (C {} { } {<--foo> } {<-n>} {($ Id.VSub_DollarName '$CONFIG_HAVE_BAR')}) terminator: ) ] ) action: [(C {} { } {<--bar>})] spids: [228 237] ) ] ) (C {} {}) ] ) (command.CommandList children: [ (command.ShFunction name: argv body: (BraceGroup children: [ (command.Sentence child: (C {<'spec/bin/argv.py'>} {(DQ ($ Id.VSub_At '$@'))}) terminator: ) ] ) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:regex) op: assign_op.Equal rhs: {(sh_array_literal left: words:[{} {}])} spids: [45] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:flags) op: assign_op.Equal rhs: {(sh_array_literal left:)} spids: [52] ) ] ) (command.ForEach iter_name: r iter_words: [ { (DQ (braced_var_sub token: bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At) ) ) } ] do_arg_iter: F body: (command.DoGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.IndexedName name: flags index: { (braced_var_sub token: prefix_op: (Id.VSub_Pound) bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At) ) } ) op: assign_op.Equal rhs: {(DQ <'--regex='> ($ Id.VSub_DollarName '$r'))} spids: [76] ) ] ) ] ) ) (C {} { (DQ (braced_var_sub token: bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At) ) ) } ) (C {} {<-s>} {} {}) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (sh_array_literal left: words:[{} {}]) ) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (sh_array_literal left:) ) (command.ForEach iter_name: r iter_words: [{}] do_arg_iter: F body: (command.DoGroup children: [ (C {} { } {(DQ <'--regex='> ($ Id.VSub_DollarName '$r'))}) ] ) ) (C {} {}) ] ) (command.CommandList children: [ (C {} {(SQ <'This is a shell script with OSH extensions!'>)}) (C {}) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (expr.Binary op: left: (Const Id.Expr_DecInt 1) right: (expr.Binary op: left: (Const Id.Expr_DecInt 2) right: (Const Id.Expr_DecInt 3) ) ) ) (C {} {(DQ <'x: '> ($ Id.VSub_DollarName '$x'))}) (command.PlaceMutation keyword: lhs: [(place_expr.Var name:)] op: rhs: (Const Id.Expr_DecInt 1) ) (C {} {(DQ <'x: '> ($ Id.VSub_DollarName '$x'))}) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (expr.List elts: [(Const Id.Expr_DecInt 1) (Const Id.Expr_DecInt 2) (Const Id.Expr_DecInt 3)] ctx: expr_context.Store ) ) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (expr.Binary op: left: (subscript obj:(Var mylist) indices:[(Const Id.Expr_DecInt 1)]) right: (Const Id.Expr_DecInt 10) ) ) (C {} {(DQ <'y: '> ($ Id.VSub_DollarName '$y'))}) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (expr.Binary op: left: (Var mylist) right: (expr.List elts: [(Const Id.Expr_DecInt 4) (Const Id.Expr_DecInt 5)] ctx: expr_context.Store ) ) ) (C {} {} {}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:str1) op: assign_op.Equal rhs: {(SQ <'shell string'>)} spids: [130] ) ] ) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (DQ <'Oil string'>) ) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (expr.Binary op: left:(Var str1) right:(Var str2)) ) (C {} {(DQ <'str3 = '> ($ Id.VSub_DollarName '$str3'))}) ] ) (command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:global_var) op: assign_op.Equal rhs: {} spids: [0] ) ] ) (command.ShFunction name: g body: (BraceGroup children: [ (C {} {} {($ Id.VSub_DollarName '$f_var')}) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (Var global_var) ) (C {} {($ Id.VSub_DollarName '$oil_var')}) ] ) ) (command.ShFunction name: f body: (BraceGroup children: [ (C {} {}) ] ) ) (C {}) ] ) (command.CommandList children: [ (C {} {<-s>} {} {}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:myglobal) op: assign_op.Equal rhs: {} spids: [10] ) ] ) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (sh_array_literal left: words: [ {($ Id.VSub_DollarName '$myglobal')} { (single_quoted left: tokens: [ ] multiline: F ) } { (braced_var_sub token: suffix_op: (suffix_op.Unary tok: arg_word:{}) ) } ] ) ) (C {<'spec/bin/argv.py'>} {}) (C {} {)} { (braced_var_sub token: suffix_op: (suffix_op.Unary tok: arg_word:{}) ) } ) (C {<'spec/bin/argv.py'>} {}) (C {} { ($ Id.VSub_DollarName '$item'))})]) ) ] ) (command.CommandList children: [ (C {} { (single_quoted left: tokens: [ ] multiline: F ) } ) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (expr.Binary op: left: (Const Id.Expr_DecInt 1) right: (expr.Binary op: left: (Const Id.Expr_DecInt 2) right: (Const Id.Expr_DecInt 3) ) ) ) (C {} { lhs: [(name_type name:)] rhs: (expr.Binary op: left: (Const Id.Expr_DecInt 5) right: (Const Id.Expr_DecInt 6) ) ) (C {} {} {}) (command.CommandList children: [ (command.Sentence child: (command.PlaceMutation keyword: lhs: [(place_expr.Var name:)] op: rhs: (Var b) ) terminator: ) (C {} {}) ] ) (command.PlaceMutation keyword: lhs: [(place_expr.Var name:)] op: rhs: (Const Id.Expr_DecInt 4) ) (command.PlaceMutation keyword: lhs: [(place_expr.Var name:)] op: rhs: (Const Id.Expr_DecInt 1) ) (command.VarDecl keyword: lhs: [(name_type name:) (name_type name:)] rhs: (expr.Tuple elts:[(Var a) (Var b)] ctx:expr_context.Store) ) (C {} {}) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (expr.Binary op: left: (command_sub left_token: child:(C {} {})) right: (DQ (command_sub left_token: child:(C {} {}))) ) ) (C {} { lhs: [(name_type name:)] rhs: (expr.Binary op: left:(${ Id.VSub_Name b) right:(DQ (${ Id.VSub_Name b))) ) (C {} { lhs: [(name_type name:)] rhs: (expr.Binary op: left: (expr.Binary op: left: (Const Id.Expr_DecInt 1) right: (Const Id.Expr_DecInt 2) ) right: (Const Id.Expr_DecInt 3) ) ) (C {} { lhs: [(name_type name:)] rhs: (expr.Binary op: left: (Const Id.Expr_DecInt 4) right: (Const Id.Expr_DecInt 5) ) ) (C {} { lhs: [(name_type name:)] rhs: (expr.Binary op: left: (Const Id.Expr_DecInt 6) right: (Const Id.Expr_DecInt 7) ) ) (C {} { lhs: [(name_type name:)] rhs: (Const Id.Expr_DecInt 8) ) (command.PlaceMutation keyword: lhs: [(place_expr.Var name:)] op: rhs: (Const Id.Expr_DecInt 9) ) (C {} {} {<-s>} { }) (command.ShFunction name: simple-demo body: (BraceGroup children: [ (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (sh_array_literal left: words: [{} {} {}] ) ) (C {} {(SQ <'+ Call in expression context:'>)}) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (expr.FuncCall func:(Var len) args:(arg_list positional:[(Var myarray)])) ) (C {} {($ Id.VSub_DollarName '$length')}) (C {}) (C {} {(SQ <'+ Inline call that coerces to string:'>)}) (C {} {<-->} { (word_part.FuncCall name: args: (arg_list positional:[(Var myarray)]) ) } {(word_part.FuncCall name: args:(arg_list positional:[(DQ )]))} {(SQ )} ) (C {}) (C {} {(SQ <'+ Inline calls can be part of a word:'>)}) (C {} {<-->} {<--length> args: (arg_list positional:[(Var myarray)]) ) } { (word_part.FuncCall name: args: (arg_list positional:[(DQ )]) ) (word_part.FuncCall name: args:(arg_list positional:[(DQ )])) } ) (C {}) (C {} {(DQ <'+ Caveat: can\'t double quote. It would break programs.'>)}) (C {} {(DQ <' Should we add an option \'shopt -s parse_dparen\'?'>)}) (C {}) (C {} {<-->} {(DQ <'--length='> ($ Id.VSub_DollarName '$len') <'(myarray)'>)}) (C {}) (C {} {(SQ <'+ Just as you can splice @myarray'>)}) (C {} {<-->} {}) (C {}) (C {} {(SQ <'+ You can also splice the result of a function returning a sequence:'>)}) (C {} {(SQ <' Notes:'>)}) (C {} {(SQ <' - the sorted() function is from Python.'>)}) (C {} {(SQ <' - sorting utf-8 encoded strings as bytes is well-defined'>)}) (C {}) (C {} {<-->} {}) (command.Subshell child:(C {})) (C {}) ] ) ) (command.ShFunction name: split-join-demo body: (BraceGroup children: [ (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (sh_array_literal left: words:[{} {} {}]) ) (C {} {<-->} {(SQ <'Parts:'>)} {}) (C {}) (C {} {(SQ <'join(parts):'>)} { (word_part.FuncCall name: args: (arg_list positional:[(Var parts)]) ) } ) (C {}) (C {} {(SQ <'+ Another way of doing it, without creating another variable:'>)}) (C {} {<-sep>} {(SQ )} {<-->} {}) (C {}) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (expr.FuncCall func:(Var join) args:(arg_list positional:[(Var parts) (DQ <':'>)])) ) (C {} {<-sep>} {(SQ )} {(DQ <'j => '>)} {($ Id.VSub_DollarName '$j')}) (C {} {<-sep>} {(SQ )} {(SQ <'When IFS is the default, split(j) => '>)}) (C {} {}) (command.Subshell child:(C {})) (C {}) (C {} {)}) (C {} {(SQ <'When IFS is :, split(j) => '>)}) (C {} {}) (command.Subshell child:(C {})) (C {}) (C {} {}) (C {} {(SQ <'+ Since there is no word splitting of unquoted $(ls), here is an idiom:'>)} ) (C {} {}) (command.Subshell child: (C { (command_sub left_token: child: (command.Pipeline children: [ (C {} {(word_part.TildeSub token:)}) (C {} {}) ] negated: F ) ) } ) ) ] ) ) (command.ShFunction name: types-demo body: (BraceGroup children:[(C {} {(SQ <'TODO: bool, int, etc.'>)})]) ) (command.ShFunction name: all body: (BraceGroup children:[(C {}) (C {})]) ) (C {(DQ ($ Id.VSub_At '$@'))}) ] ) (command.CommandList children: [ (command.Proc name: sig: (proc_sig.Open) body: (BraceGroup children: [ (C {} {<-c>} {(SQ <'import sys;print(sys.argv[1:])'>)} {}) ] ) ) (command.Proc name: sig: (proc_sig.Open) body: (BraceGroup children: [(C {} {(SQ <'====='>)}) (C {} {}) (C {})] ) ) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (sh_array_literal left: words: [ {} {} { <.sh>} (word.BracedTree parts: [(word_part.BracedTuple words:[{} {}]) <.com>] ) {(SQ )} { (DQ <'dq '> (braced_var_sub token: suffix_op: (suffix_op.Unary tok: arg_word:{}) ) ) } ] ) ) (C {} {}) (command.VarDecl keyword: lhs: [(name_type name:)] rhs: (command_sub left_token: child: (C {} {} {} { <.sh>} (word.BracedTree parts: [(word_part.BracedTuple words:[{} {}]) <.com>] ) {(SQ )} { (DQ <'dq '> (braced_var_sub token: suffix_op: (suffix_op.Unary tok: arg_word:{}) ) ) } ) ) ) (C {} {($ Id.VSub_DollarName '$cmd_sub')}) (C {} { (word_part.ExprSub left: child: (expr.Binary op: left: (SQ <'quoted '>) right: (expr.Binary op: left: (SQ <'words '>) right: (DQ <'dq '> (braced_var_sub token: suffix_op: (suffix_op.Unary tok: arg_word: {} ) ) ) ) ) ) } ) ] ) oil_lang/testdata/array-rewrite-1.sh --- ['--regex=old1', '--regex=old2'] ['--regex=new1', '--regex=new2'] oil_lang/testdata/array-rewrite-2.sh --- ['--foo=/etc/path', 'with', 'spaces'] ['--foo=/etc/path with spaces'] oil_lang/testdata/inline-function-calls.sh skipping oil_lang/testdata/inline-function-calls.sh oil_lang/testdata/sigil-pairs.sh --- ===== ['@ARGV'] ===== ['@ARGV'] ===== ['@ARGV'] oil_lang/testdata/array-splice-demo.osh --- shopt -s oil-parse-at static-word-eval ^~~~~ oil_lang/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 oil_lang/testdata/assign.osh skipping oil_lang/testdata/assign.osh oil_lang/testdata/hello.osh --- This is a shell script with OSH extensions! x: 7 x: 8 y: 20 list2 = (cell exported:F readonly:F nameref:F val:(value.Obj obj:[1, 2, 3, 4, 5])) str3 = shell stringOil string oil_lang/testdata/no-dynamic-scope.osh skipping oil_lang/testdata/no-dynamic-scope.osh --- 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 mu = μ 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 2021 Here I am! could be anything really date: unrecognized option '--wrong-flag' Try 'date --help' for more information. there was an error number 2021-09-16 2021