(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:date) op: assign_op.Equal rhs: {(DQ (command_sub left_token:<Id.Left_Backtick '`'> child:(C {<which>} {<date>})))} spids: [19] ) ] ) (command.ShFunction name: daysInMonth body: (BraceGroup children: [ (command.Case to_match: {($ Id.VSub_Number '$1')} arms: [ (case_arm pat_list: [{<1>} {<3>} {<5>} {<7>} {<8>} {<10>} {<12>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dim) op: assign_op.Equal rhs: {<31>} spids: [61] ) ] ) ] spids: [45 59 64 -1] ) (case_arm pat_list: [{<4>} {<6>} {<9>} {<11>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dim) op: assign_op.Equal rhs: {<30>} spids: [80] ) ] ) ] spids: [70 78 83 -1] ) (case_arm pat_list: [{<2>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dim) op: assign_op.Equal rhs: {<29>} spids: [90] ) ] ) ] spids: [86 88 93 -1] ) (case_arm pat_list: [{<Id.Lit_Star '*'>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dim) op: assign_op.Equal rhs: {<-1>} spids: [103] ) ] ) ] spids: [99 101 106 -1] ) ] ) ] ) ) (command.ShFunction name: isleap body: (BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:leapyear) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (command.Pipeline children: [ (C {($ Id.VSub_DollarName '$date')} {<-d>} {<'12/31/'> ($ Id.VSub_Number '$1')} {<Id.Lit_Other '+'> <Id.Lit_Other '%'> <j>} ) (C {<grep>} {<366>}) ] negated: F ) ) } spids: [129] ) ] ) ] ) ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_Pound '$#')} {<-ne>} {<3>} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (C {<echo>} { (DQ <'Usage: '> (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<basename>} {($ Id.VSub_Number '$0')}) ) <' mon day year'> ) } ) (C {<echo>} {(DQ <' with just numerical values (ex: 1 1 2020)'>)}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] spids: [159 173] ) ] ) (command.Simple words: [{($ Id.VSub_DollarName '$date')} {<--version>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<'/dev/null'>}) (redir op:<Id.Redir_GreatAnd '2>&'> loc:(redir_loc.Fd fd:2) arg:{<1>}) ] do_fork: T ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_QMark '$?')} {<-ne>} {<0>} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Simple words: [ {<echo>} { (DQ <'Sorry, but '> (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<basename>} {($ Id.VSub_Number '$0')}) ) <' can\'t run without GNU date.'> ) } ] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] spids: [218 232] ) ] ) (C {<eval>} { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {($ Id.VSub_DollarName '$date')} {(DQ <'+thismon=%m;thisday=%d;thisyear=%Y;dayofyear=%j'>)} ) ) } ) (command.CommandList children: [ (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:endmon) op: assign_op.Equal rhs: {($ Id.VSub_Number '$1')} spids: [269] ) ] ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:endday) op: assign_op.Equal rhs: {($ Id.VSub_Number '$2')} spids: [273] ) ] ) terminator: <Id.Op_Semi _> ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:endyear) op: assign_op.Equal rhs: {($ Id.VSub_Number '$3')} spids: [277] ) ] ) ] ) (C {<daysInMonth>} {($ Id.VSub_DollarName '$endmon')}) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$endday')} {<-lt>} {<0>} {<-o>} {($ Id.VSub_DollarName '$endday')} {<-gt>} {($ Id.VSub_DollarName '$dim')} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Sentence child: (command.Simple words: [ {<echo>} { (DQ <'Invalid: Month #'> ($ Id.VSub_DollarName '$endmon') <' only has '> ($ Id.VSub_DollarName '$dim') <' days.'> ) } ] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) terminator: <Id.Op_Semi _> ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] spids: [292 314] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$endmon')} {<-eq>} {<2>} {<-a>} {($ Id.VSub_DollarName '$endday')} {<-eq>} {<29>} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (C {<isleap>} {($ Id.VSub_DollarName '$endyear')}) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ ($ Id.VSub_DollarName '$leapyear'))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Simple words: [ {<echo>} { (DQ <'Invalid: '> ($ Id.VSub_DollarName '$endyear') <' wasn\'t a leapyear, so February only had 28 days.'> ) } ] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] spids: [369 383] ) ] ) ] spids: [339 361] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$endyear')} {<-lt>} {($ Id.VSub_DollarName '$thisyear')} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Sentence child: (command.Simple words: [ {<echo>} { (DQ <'Invalid: '> ($ Id.VSub_DollarName '$endmon') <'/'> ($ Id.VSub_DollarName '$endday') <'/'> ($ Id.VSub_DollarName '$endyear') <' is prior to the current year.'> ) } ] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) terminator: <Id.Op_Semi _> ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] spids: [408 422] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$endyear')} {<-eq>} {($ Id.VSub_DollarName '$thisyear')} {<-a>} {($ Id.VSub_DollarName '$endmon')} {<-lt>} {($ Id.VSub_DollarName '$thismon')} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Sentence child: (command.Simple words: [ {<echo>} { (DQ <'Invalid: '> ($ Id.VSub_DollarName '$endmon') <'/'> ($ Id.VSub_DollarName '$endday') <'/'> ($ Id.VSub_DollarName '$endyear') <' is prior to the current month.'> ) } ] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) terminator: <Id.Op_Semi _> ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] spids: [449 471] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$endyear')} {<-eq>} {($ Id.VSub_DollarName '$thisyear')} {<-a>} {($ Id.VSub_DollarName '$endmon')} {<-eq>} {($ Id.VSub_DollarName '$thismon')} {<-a>} {($ Id.VSub_DollarName '$endday')} {<-lt>} {($ Id.VSub_DollarName '$thisday')} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Sentence child: (command.Simple words: [ {<echo>} { (DQ <'Invalid: '> ($ Id.VSub_DollarName '$endmon') <'/'> ($ Id.VSub_DollarName '$endday') <'/'> ($ Id.VSub_DollarName '$endyear') <' is prior to the current date.'> ) } ] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) terminator: <Id.Op_Semi _> ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] spids: [498 528] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$endyear')} {<-eq>} {($ Id.VSub_DollarName '$thisyear')} {<-a>} {($ Id.VSub_DollarName '$endmon')} {<-eq>} {($ Id.VSub_DollarName '$thismon')} {<-a>} {($ Id.VSub_DollarName '$endday')} {<-eq>} {($ Id.VSub_DollarName '$thisday')} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Sentence child: (command.Simple words: [ {<echo>} { (DQ <'There are zero days between '> ($ Id.VSub_DollarName '$endmon') <'/'> ($ Id.VSub_DollarName '$endday') <'/'> ($ Id.VSub_DollarName '$endyear') <' and today.'> ) } ] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) terminator: <Id.Op_Semi _> ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<0>}) ] spids: [555 585] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$endyear')} {<-eq>} {($ Id.VSub_DollarName '$thisyear')} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:totaldays) op: assign_op.Equal rhs: { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Minus left: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {($ Id.VSub_DollarName '$date')} {<-d>} { (DQ ($ Id.VSub_DollarName '$endmon') <'/'> ($ Id.VSub_DollarName '$endday') <'/'> ($ Id.VSub_DollarName '$endyear') ) } {<Id.Lit_Other '+'> <Id.Lit_Other '%'> <j>} ) ) } right: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {($ Id.VSub_DollarName '$date')} {<Id.Lit_Other '+'> <Id.Lit_Other '%'> <j>} ) ) } ) ) } spids: [634] ) ] ) ] spids: [616 630] ) ] else_action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:thisdatefmt) op: assign_op.Equal rhs: { (DQ ($ Id.VSub_DollarName '$thismon') <'/'> ($ Id.VSub_DollarName '$thisday') <'/'> ($ Id.VSub_DollarName '$thisyear') ) } spids: [689] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:calculate) op: assign_op.Equal rhs: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {($ Id.VSub_DollarName '$date')} {<-d>} {(DQ <'12/31/'> ($ Id.VSub_DollarName '$thisyear'))} {<Id.Lit_Other '+'> <Id.Lit_Other '%'> <j>} ) ) <' - '> (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {($ Id.VSub_DollarName '$date')} {<-d>} {($ Id.VSub_DollarName '$thisdatefmt')} {<Id.Lit_Other '+'> <Id.Lit_Other '%'> <j>} ) ) ) } spids: [700] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:daysleftinyear) op: assign_op.Equal rhs: {(word_part.ArithSub anode:{($ Id.VSub_DollarName '$calculate')})} spids: [732] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:daysbetweenyears) op: assign_op.Equal rhs: {<0>} spids: [747] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:tempyear) op: assign_op.Equal rhs: { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Plus left: {($ Id.VSub_DollarName '$thisyear')} right: {<Id.Lit_Digits 1>} ) ) } spids: [751] ) ] ) (command.WhileUntil keyword: <Id.KW_While while> cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$tempyear')} {<-lt>} {($ Id.VSub_DollarName '$endyear')} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) body: (command.DoGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:daysbetweenyears) op: assign_op.Equal rhs: { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Plus left: {($ Id.VSub_DollarName '$daysbetweenyears')} right: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {($ Id.VSub_DollarName '$date')} {<-d>} {(DQ <'12/31/'> ($ Id.VSub_DollarName '$tempyear'))} {<Id.Lit_Other '+'> <Id.Lit_Other '%'> <j>} ) ) } ) ) } spids: [782] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:tempyear) op: assign_op.Equal rhs: { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Plus left: {($ Id.VSub_DollarName '$tempyear')} right: {<Id.Lit_Digits 1>} ) ) } spids: [808] ) ] ) ] ) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dayofyear) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {($ Id.VSub_DollarName '$date')} {<--date>} {($ Id.VSub_DollarName '$endmon') <'/'> ($ Id.VSub_DollarName '$endday') <'/'> ($ Id.VSub_DollarName '$endyear') } {<Id.Lit_Other '+'> <Id.Lit_Other '%'> <j>} ) ) } spids: [830] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:totaldays) 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_Plus left: {($ Id.VSub_DollarName '$daysleftinyear')} right: {($ Id.VSub_DollarName '$daysbetweenyears')} ) right: {($ Id.VSub_DollarName '$dayofyear')} ) ) } spids: [857] ) ] ) ] ) (C {<echo>} { (DQ <'There are '> ($ Id.VSub_DollarName '$totaldays') <' days until the date '> ($ Id.VSub_DollarName '$endmon') <'/'> ($ Id.VSub_DollarName '$endday') <'/'> ($ Id.VSub_DollarName '$endyear') <.> ) } ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<0>}) ] )