(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:retries)
          op: assign_op.Equal
          rhs: {(DQ (10))}
          spids: [7]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:action)
          op: assign_op.Equal
          rhs: {(DQ (lock))}
          spids: [15]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:nullcmd)
          op: assign_op.Equal
          rhs: 
            {
              (DQ 
                (command_sub
                  left_token: (Token id:Id.Left_Backtick val:'`' span_id:25)
                  command_list: (command.CommandList children:[(C {(which)} {(true)})])
                )
              )
            }
          spids: [23]
        )
      ]
    )
    (command.WhileUntil
      keyword: (Token id:Id.KW_While val:while span_id:38)
      cond: [
        (command.Sentence
          child: (C {(getopts)} {(DQ ('lur:'))} {(opt)})
          terminator: (Token id:Id.Op_Semi val:';' span_id:47)
        )
      ]
      body: 
        (command.DoGroup
          children: [
            (command.Case
              to_match: {($ Id.VSub_DollarName '$opt')}
              arms: [
                (case_arm
                  pat_list: [{(l)}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:action)
                          op: assign_op.Equal
                          rhs: {(DQ (lock))}
                          spids: [63]
                        )
                      ]
                    )
                  ]
                  spids: [59 61 68 -1]
                )
                (case_arm
                  pat_list: [{(u)}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:action)
                          op: assign_op.Equal
                          rhs: {(DQ (unlock))}
                          spids: [75]
                        )
                      ]
                    )
                  ]
                  spids: [71 73 80 -1]
                )
                (case_arm
                  pat_list: [{(r)}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:retries)
                          op: assign_op.Equal
                          rhs: {(DQ ($ Id.VSub_DollarName '$OPTARG'))}
                          spids: [87]
                        )
                      ]
                    )
                  ]
                  spids: [83 85 92 -1]
                )
              ]
            )
          ]
        )
    )
    (C {(shift)} 
      {
        (word_part.ArithSub
          anode: 
            (arith_expr.Binary
              op_id: Id.Arith_Minus
              left: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$OPTIND')})
              right: (arith_expr.ArithWord w:{(Id.Lit_Digits 1)})
            )
        )
      }
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {(Id.Lit_LBracket '[')} {($ Id.VSub_Pound '$#')} {(-eq)} {(0)} {(Id.Lit_RBracket ']')})
              terminator: (Token id:Id.Op_Semi val:';' span_id:123)
            )
          ]
          action: [
            (command.Simple
              words: [{(cat)}]
              redirects: [
                (redir.HereDoc
                  op: (Token id:Id.Redir_DLess val:'<<' span_id:133)
                  fd: -1
                  here_begin: {(EOF)}
                  here_end_span_id: 148
                  stdin_parts: [
                    ('Usage: ')
                    ($ Id.VSub_Number '$0')
                    (' [-l|-u] [-r retries] LOCKFILE\n')
                    ('Where -l requests a lock (the default), -u requests an unlock, -r X \n')
                    ('specifies a max number of retries before it fails (default = ')
                    ($ Id.VSub_DollarName '$retries')
                    (').\n')
                  ]
                )
                (redir.Redir
                  op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:137)
                  fd: -1
                  arg_word: {(2)}
                )
              ]
            )
            (command.ControlFlow
              token: (Token id:Id.ControlFlow_Exit val:exit span_id:150)
              arg_word: {(1)}
            )
          ]
          spids: [111 125]
        )
      ]
    )
    (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:168)
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.Pipeline
                                children: [
                                  (C {(which)} {(lockfile)})
                                  (C {(grep)} {(-v)} 
                                    {(SQ (Token id:Id.Lit_Chars val:'^no ' span_id:180))}
                                  )
                                ]
                                negated: F
                              )
                            ]
                          )
                      )
                    )
                  } {(Id.Lit_RBracket ']')}
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:187)
            )
          ]
          action: [
            (command.Simple
              words: [
                {(echo)}
                {(DQ ($ Id.VSub_Number '$0') (" failed: 'lockfile' utility not found in PATH."))}
              ]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:199)
                  fd: -1
                  arg_word: {(2)}
                )
              ]
            )
            (command.ControlFlow
              token: (Token id:Id.ControlFlow_Exit val:exit span_id:203)
              arg_word: {(1)}
            )
          ]
          spids: [161 189]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {(Id.Lit_LBracket '[')} {(DQ ($ Id.VSub_DollarName '$action'))} {(Id.Lit_Equals '=')} 
                  {(DQ (lock))} {(Id.Lit_RBracket ']')}
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:225)
            )
          ]
          action: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.Pipeline
                          children: [
                            (command.Simple
                              words: [
                                {(lockfile)}
                                {(-1)}
                                {(-r)}
                                {($ Id.VSub_DollarName '$retries')}
                                {(DQ ($ Id.VSub_Number '$1'))}
                              ]
                              redirects: [
                                (redir.Redir
                                  op: (Token id:Id.Redir_Great val:'2>' span_id:246)
                                  fd: 2
                                  arg_word: {(/dev/null)}
                                )
                              ]
                            )
                          ]
                          negated: T
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:249)
                    )
                  ]
                  action: [
                    (command.Simple
                      words: [
                        {(echo)}
                        {(DQ ($ Id.VSub_Number '$0') (": Failed: Couldn't create lockfile in time"))}
                      ]
                      redirects: [
                        (redir.Redir
                          op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:261)
                          fd: -1
                          arg_word: {(2)}
                        )
                      ]
                    )
                    (command.ControlFlow
                      token: (Token id:Id.ControlFlow_Exit val:exit span_id:265)
                      arg_word: {(1)}
                    )
                  ]
                  spids: [230 251]
                )
              ]
            )
          ]
          spids: [209 227]
        )
      ]
      else_action: [
        (command.If
          arms: [
            (if_arm
              cond: [
                (command.Sentence
                  child: 
                    (C {(Id.Lit_LBracket '[')} {(Id.KW_Bang '!')} {(-f)} {(DQ ($ Id.VSub_Number '$1'))} 
                      {(Id.Lit_RBracket ']')}
                    )
                  terminator: (Token id:Id.Op_Semi val:';' span_id:292)
                )
              ]
              action: [
                (command.Simple
                  words: [
                    {(echo)}
                    {
                      (DQ ($ Id.VSub_Number '$0') (': Warning: lockfile ') ($ Id.VSub_Number '$1') 
                        (" doesn't exist to unlock")
                      )
                    }
                  ]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:306)
                      fd: -1
                      arg_word: {(2)}
                    )
                  ]
                )
                (command.ControlFlow
                  token: (Token id:Id.ControlFlow_Exit val:exit span_id:310)
                  arg_word: {(1)}
                )
              ]
              spids: [278 294]
            )
          ]
        )
        (C {(rm)} {(-f)} {(DQ ($ Id.VSub_Number '$1'))})
      ]
    )
    (command.ControlFlow token:(Token id:Id.ControlFlow_Exit val:exit span_id:329) arg_word:{(0)})
  ]
)