(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:agendafile)
          op: assign_op.Equal
          rhs: {(DQ ($ Id.VSub_DollarName '$HOME') <'/.agenda'>)}
          spids: [8]
        )
      ]
    )
    (command.ShFunction
      name: isDayName
      body: 
        (BraceGroup
          children: [
            (command.Case
              to_match: 
                {
                  (command_sub
                    left_token: <Id.Left_DollarParen '$('>
                    child: 
                      (command.Pipeline
                        children: [
                          (C {<echo>} {($ Id.VSub_Number '$1')})
                          (C {<tr>} {(SQ <'[[:upper:]]'>)} {(SQ <'[[:lower:]]'>)})
                        ]
                        negated: F
                      )
                  )
                }
              arms: [
                (case_arm
                  pat_list: [
                    {<sun> <Id.Lit_Star '*'>}
                    {<mon> <Id.Lit_Star '*'>}
                    {<tue> <Id.Lit_Star '*'>}
                    {<wed> <Id.Lit_Star '*'>}
                    {<thu> <Id.Lit_Star '*'>}
                    {<fri> <Id.Lit_Star '*'>}
                    {<sat> <Id.Lit_Star '*'>}
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:retval)
                          op: assign_op.Equal
                          rhs: {<0>}
                          spids: [72]
                        )
                      ]
                    )
                  ]
                  spids: [50 70 75 -1]
                )
                (case_arm
                  pat_list: [{<Id.Lit_Star '*'>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:retval)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [82]
                        )
                      ]
                    )
                  ]
                  spids: [78 80 85 -1]
                )
              ]
            )
            (command.ControlFlow
              token: <Id.ControlFlow_Return return>
              arg_word: {($ Id.VSub_DollarName '$retval')}
            )
          ]
        )
    )
    (command.ShFunction
      name: isMonthName
      body: 
        (BraceGroup
          children: [
            (command.Case
              to_match: 
                {
                  (command_sub
                    left_token: <Id.Left_DollarParen '$('>
                    child: 
                      (command.Pipeline
                        children: [
                          (C {<echo>} {($ Id.VSub_Number '$1')})
                          (C {<tr>} {(SQ <'[[:upper:]]'>)} {(SQ <'[[:lower:]]'>)})
                        ]
                        negated: F
                      )
                  )
                }
              arms: [
                (case_arm
                  pat_list: [
                    {<jan> <Id.Lit_Star '*'>}
                    {<feb> <Id.Lit_Star '*'>}
                    {<mar> <Id.Lit_Star '*'>}
                    {<apr> <Id.Lit_Star '*'>}
                    {<may> <Id.Lit_Star '*'>}
                    {<jun> <Id.Lit_Star '*'>}
                  ]
                  action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})]
                  spids: [129 146 152 -1]
                )
                (case_arm
                  pat_list: [
                    {<jul> <Id.Lit_Star '*'>}
                    {<aug> <Id.Lit_Star '*'>}
                    {<sep> <Id.Lit_Star '*'>}
                    {<oct> <Id.Lit_Star '*'>}
                    {<nov> <Id.Lit_Star '*'>}
                    {<dec> <Id.Lit_Star '*'>}
                  ]
                  action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})]
                  spids: [155 172 178 -1]
                )
                (case_arm
                  pat_list: [{<Id.Lit_Star '*'>}]
                  action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})]
                  spids: [181 183 189 -1]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: normalize
      body: 
        (BraceGroup
          children: [
            (command.Pipeline
              children: [
                (C {<'/bin/echo'>} {<-n>} {($ Id.VSub_Number '$1')})
                (C {<cut>} {<-c1>})
                (C {<tr>} {(SQ <'[[:lower:]]'>)} {(SQ <'[[:upper:]]'>)})
              ]
              negated: F
            )
            (command.Pipeline
              children: [
                (C {<echo>} {($ Id.VSub_Number '$1')})
                (C {<cut>} {<-c2-3>})
                (C {<tr>} {(SQ <'[[:upper:]]'>)} {(SQ <'[[:lower:]]'>)})
              ]
              negated: F
            )
          ]
        )
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-w>} {($ Id.VSub_DollarName '$HOME')} 
                      {<Id.Lit_RBracket ']'>}
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (command.Simple
              words: [
                {<echo>}
                {
                  (DQ ($ Id.VSub_Number '$0') <': cannot write in your home directory ('> 
                    ($ Id.VSub_DollarName '$HOME') <')'>
                  )
                }
              ]
              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: [258 272]
        )
      ]
    )
    (C {<echo>} {(DQ <'Agenda: The Unix Reminder Service'>)})
    (C {<'/bin/echo'>} {<-n>} {(DQ <'Date of event (day mon, day month year, or dayname): '>)})
    (C {<read>} {<word1>} {<word2>} {<word3>} {<junk>})
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: (C {<isDayName>} {($ Id.VSub_DollarName '$word1')})
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-z>} 
                              {(DQ ($ Id.VSub_DollarName '$word2'))} {<Id.Lit_RBracket ']'>}
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.Simple
                      words: [
                        {<echo>}
                        {(DQ <'Bad dayname format: just specify the day name by itself.'>)}
                      ]
                      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: [331 347]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:date)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (command_sub
                          left_token: <Id.Left_DollarParen '$('>
                          child: (C {<normalize>} {($ Id.VSub_DollarName '$word1')})
                        )
                      )
                    }
                  spids: [368]
                )
              ]
            )
          ]
          spids: [320 328]
        )
      ]
      else_action: [
        (command.If
          arms: [
            (if_arm
              cond: 
                (condition.Shell
                  commands: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ ($ Id.VSub_DollarName '$word2'))} 
                          {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              action: [
                (command.Simple
                  words: [{<echo>} {(DQ <'Bad dayname format: unknown day name specified'>)}]
                  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: [382 396]
            )
          ]
        )
        (command.If
          arms: [
            (if_arm
              cond: 
                (condition.Shell
                  commands: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-z>} 
                          {
                            (DQ 
                              (command_sub
                                left_token: <Id.Left_DollarParen '$('>
                                child: 
                                  (command.Pipeline
                                    children: [
                                      (C {<echo>} {($ Id.VSub_DollarName '$word1')})
                                      (C {<sed>} {(SQ <'s/[[:digit:]]//g'>)})
                                    ]
                                    negated: F
                                  )
                              )
                            )
                          } {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              action: [
                (command.Simple
                  words: [{<echo>} {(DQ <'Bad date format: please specify day first, by day number'>)}]
                  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: [418 444]
            )
          ]
        )
        (command.If
          arms: [
            (if_arm
              cond: 
                (condition.Shell
                  commands: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$word1'))} {<-lt>} {<1>} 
                          {<-o>} {(DQ ($ Id.VSub_DollarName '$word1'))} {<-gt>} {<31>} {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              action: [
                (command.Simple
                  words: [{<echo>} {(DQ <'Bad date format: day number can only be in range 1-31'>)}]
                  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: [466 492]
            )
          ]
        )
        (command.If
          arms: [
            (if_arm
              cond: 
                (condition.Shell
                  commands: [
                    (command.Sentence
                      child: 
                        (command.Pipeline
                          children: [(C {<isMonthName>} {(DQ ($ Id.VSub_DollarName '$word2'))})]
                          negated: T
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              action: [
                (command.Simple
                  words: [{<echo>} {(DQ <'Bad date format: unknown month name specified.'>)}]
                  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: [514 526]
            )
          ]
        )
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:word2)
              op: assign_op.Equal
              rhs: 
                {
                  (DQ 
                    (command_sub
                      left_token: <Id.Left_DollarParen '$('>
                      child: (C {<normalize>} {($ Id.VSub_DollarName '$word2')})
                    )
                  )
                }
              spids: [548]
            )
          ]
        )
        (command.If
          arms: [
            (if_arm
              cond: 
                (condition.Shell
                  commands: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ ($ Id.VSub_DollarName '$word3'))} 
                          {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              action: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:date)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_DollarName '$word1') ($ Id.VSub_DollarName '$word2'))}
                      spids: [576]
                    )
                  ]
                )
              ]
              spids: [559 573]
            )
          ]
          else_action: [
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-z>} 
                              {
                                (DQ 
                                  (command_sub
                                    left_token: <Id.Left_DollarParen '$('>
                                    child: 
                                      (command.Pipeline
                                        children: [
                                          (C {<echo>} {($ Id.VSub_DollarName '$word3')})
                                          (C {<sed>} {(SQ <'s/[[:digit:]]//g'>)})
                                        ]
                                        negated: F
                                      )
                                  )
                                )
                              } {<Id.Lit_RBracket ']'>}
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.Simple
                      words: [{<echo>} {(DQ <'Bad date format: third field should be year.'>)}]
                      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: [586 612]
                )
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$word3')} {<-lt>} {<2000>} 
                              {<-o>} {($ Id.VSub_DollarName '$word3')} {<-gt>} {<2500>} {<Id.Lit_RBracket ']'>}
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.Simple
                      words: [{<echo>} {(DQ <'Bad date format: year value should be 2000-2500'>)}]
                      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: [630 652]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:date)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ ($ Id.VSub_DollarName '$word1') ($ Id.VSub_DollarName '$word2') 
                        ($ Id.VSub_DollarName '$word3')
                      )
                    }
                  spids: [673]
                )
              ]
            )
          ]
        )
      ]
    )
    (C {<'/bin/echo'>} {<-n>} {(DQ <'One-line description: '>)})
    (C {<read>} {<description>})
    (command.Simple
      words: [
        {<echo>}
        {
          (DQ 
            (command_sub
              left_token: <Id.Left_DollarParen '$('>
              child: 
                (command.Pipeline
                  children: [(C {<echo>} {($ Id.VSub_DollarName '$date')}) (C {<sed>} {(SQ <'s/ //g'>)})]
                  negated: F
                )
            ) <'|'> ($ Id.VSub_DollarName '$description')
          )
        }
      ]
      redirects: [
        (redir
          op: <Id.Redir_DGreat '>>'>
          loc: (redir_loc.Fd fd:1)
          arg: {($ Id.VSub_DollarName '$agendafile')}
        )
      ]
      do_fork: T
    )
    (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<0>})
  ]
)