(command.CommandList children: [ (command.ShFunction name: rolldie body: (command.BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dice) op: assign_op.Equal rhs: {($ Id.VSub_Number '$1')} spids: [23] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dicecount) op: assign_op.Equal rhs: {(1)} spids: [27] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:sum) op: assign_op.Equal rhs: {(0)} spids: [31] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {(Id.Lit_LBracket '[')} {(-z)} { (DQ (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:48) command_list: (command.CommandList children: [ (command.Pipeline children: [ (C {(echo)} {($ Id.VSub_DollarName '$dice')}) (C {(grep)} {(SQ (Token id:Id.Lit_Chars val:d span_id:58))}) ] negated: F ) ] ) ) ) } {(Id.Lit_RBracket ']')} ) terminator: (Token id:Id.Op_Semi val:';' span_id:65) ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:quantity) op: assign_op.Equal rhs: {(1)} spids: [70] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:sides) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$dice')} spids: [74] ) ] ) ] spids: [41 67] ) ] else_action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:quantity) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:82) command_list: (command.CommandList children: [ (command.Pipeline children: [ (C {(echo)} {($ Id.VSub_DollarName '$dice')}) (C {(cut)} {(-dd)} {(-f1)}) ] negated: F ) ] ) ) } spids: [81] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {(Id.Lit_LBracket '[')} {(-z)} {(DQ ($ Id.VSub_DollarName '$quantity'))} {(Id.Lit_RBracket ']')} ) terminator: (Token id:Id.Op_Semi val:';' span_id:109) ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:quantity) op: assign_op.Equal rhs: {(1)} spids: [117] ) ] ) ] spids: [97 111] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:sides) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:125) command_list: (command.CommandList children: [ (command.Pipeline children: [ (C {(echo)} {($ Id.VSub_DollarName '$dice')}) (C {(cut)} {(-dd)} {(-f2)}) ] negated: F ) ] ) ) } spids: [124] ) ] ) ] ) (command.Sentence child: (C {(echo)} {(DQ )}) terminator: (Token id:Id.Op_Semi val:';' span_id:149) ) (C {(echo)} { (DQ ('rolling ') ($ Id.VSub_DollarName '$quantity') (' ') ($ Id.VSub_DollarName '$sides') ('-sided die') ) } ) (command.WhileUntil keyword: (Token id:Id.KW_While val:while span_id:168) cond: [ (command.Sentence child: (C {(Id.Lit_LBracket '[')} {($ Id.VSub_DollarName '$dicecount')} {(-le)} {($ Id.VSub_DollarName '$quantity')} {(Id.Lit_RBracket ']')} ) terminator: (Token id:Id.Op_Semi val:';' span_id:180) ) ] body: (command.DoGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:roll) op: assign_op.Equal rhs: { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Plus left: (arith_expr.Binary op_id: Id.Arith_Percent left: (arith_expr.ArithWord w: {($ Id.VSub_DollarName '$RANDOM')} ) right: (arith_expr.ArithWord w: {($ Id.VSub_DollarName '$sides')} ) ) right: (arith_expr.ArithWord w:{(Id.Lit_Digits 1)}) ) ) } spids: [185] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:sum) op: assign_op.Equal rhs: { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Plus left: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$sum')}) right: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$roll')}) ) ) } spids: [206] ) ] ) (C {(echo)} { (DQ (' roll #') ($ Id.VSub_DollarName '$dicecount') (' = ') ($ Id.VSub_DollarName '$roll') ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dicecount) op: assign_op.Equal rhs: { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Plus left: (arith_expr.ArithWord w: {($ Id.VSub_DollarName '$dicecount')} ) right: (arith_expr.ArithWord w:{(Id.Lit_Digits 1)}) ) ) } spids: [229] ) ] ) ] ) ) (C {(echo)} {(I)} {(rolled)} {($ Id.VSub_DollarName '$dice')} {(and)} {(it)} {(added)} {(up)} {(to)} {($ Id.VSub_DollarName '$sum')} ) ] ) ) (command.WhileUntil keyword: (Token id:Id.KW_While val:while span_id:269) cond: [ (command.Sentence child: (C {(Id.Lit_LBracket '[')} {($ Id.VSub_Pound '$#')} {(-gt)} {(0)} {(Id.Lit_RBracket ']')}) terminator: (Token id:Id.Op_Semi val:';' span_id:281) ) ] body: (command.DoGroup children: [ (C {(rolldie)} {($ Id.VSub_Number '$1')}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:sumtotal) op: assign_op.Equal rhs: { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Plus left: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$sumtotal')}) right: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$sum')}) ) ) } spids: [291] ) ] ) (C {(shift)}) ] ) ) (C {(echo)} {(DQ )}) (C {(echo)} {(DQ ('In total, all of those dice add up to ') ($ Id.VSub_DollarName '$sumtotal'))}) (C {(echo)} {(DQ )}) (command.ControlFlow token:(Token id:Id.ControlFlow_Exit val:exit span_id:326) arg_word:{(0)}) ] )