(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:tid)
          op: assign_op.Equal
          rhs: {(DQ <'agent timeout test'>)}
          spids: [7]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:SSHAGENT_TIMEOUT)
          op: assign_op.Equal
          rhs: {<10>}
          spids: [13]
        )
      ]
    )
    (C {<trace>} {(DQ <'start agent'>)})
    (command.Simple
      words: [
        {<eval>}
        {(command_sub left_token:<Id.Left_Backtick '`'> child:(C {(${ Id.VSub_Name SSHAGENT)} {<-s>}))}
      ]
      redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<'/dev/null'>})]
      do_fork: T
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:r)
          op: assign_op.Equal
          rhs: {($ Id.VSub_QMark '$?')}
          spids: [39]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$r')} {<-ne>} {<0>} 
                      {<Id.Lit_RBracket ']'>}
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (C {<fail>} {(DQ <'could not start ssh-agent: exit code '> ($ Id.VSub_DollarName '$r'))})
          ]
          spids: [42 55]
        )
      ]
      else_action: [
        (C {<trace>} {(DQ <'add keys with timeout'>)})
        (command.ForEach
          iter_name: t
          iter_words: [{(${ Id.VSub_Name SSH_KEYTYPES)}]
          do_arg_iter: F
          body: 
            (command.DoGroup
              children: [
                (command.Simple
                  words: [
                    {(${ Id.VSub_Name SSHADD)}
                    {<-t>}
                    {(${ Id.VSub_Name SSHAGENT_TIMEOUT)}
                    {($ Id.VSub_DollarName '$OBJ') <'/'> ($ Id.VSub_DollarName '$t')}
                  ]
                  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: [(C {<fail>} {(DQ <'ssh-add did succeed exit code 0'>)})]
                      spids: [111 124]
                    )
                  ]
                )
              ]
            )
        )
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:n)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: <Id.Left_Backtick '`'>
                    child: 
                      (command.Pipeline
                        children: [
                          (command.Simple
                            words: [{(${ Id.VSub_Name SSHADD)} {<-l>}]
                            redirects: [
                              (redir
                                op: <Id.Redir_Great '2>'>
                                loc: (redir_loc.Fd fd:2)
                                arg: {<'/dev/null'>}
                              )
                            ]
                            do_fork: T
                          )
                          (C {<wc>} {<-l>})
                        ]
                        negated: F
                      )
                  )
                }
              spids: [140]
            )
          ]
        )
        (C {<trace>} {(DQ <'agent has '> ($ Id.VSub_DollarName '$n') <' keys'>)})
        (command.If
          arms: [
            (if_arm
              cond: 
                (condition.Shell
                  commands: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {($ Id.VSub_DollarName '$n')} {<-ne>} {<2>} 
                          {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              action: [
                (C {<fail>} {(DQ <'ssh-add -l did not return 2 keys: '> ($ Id.VSub_DollarName '$n'))})
              ]
              spids: [171 184]
            )
          ]
        )
        (C {<trace>} {(DQ <'sleeping 2*'> (${ Id.VSub_Name SSHAGENT_TIMEOUT) <' seconds'>)})
        (C {<sleep>} {(${ Id.VSub_Name SSHAGENT_TIMEOUT)})
        (C {<sleep>} {(${ Id.VSub_Name SSHAGENT_TIMEOUT)})
        (command.Pipeline
          children: [
            (command.Simple
              words: [{(${ Id.VSub_Name SSHADD)} {<-l>}]
              redirects: [(redir op:<Id.Redir_Great '2>'> loc:(redir_loc.Fd fd:2) arg:{<'/dev/null'>})]
              do_fork: T
            )
            (command.Simple
              words: [{<grep>} {(SQ <'The agent has no identities.'>)}]
              redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<'/dev/null'>})]
              do_fork: T
            )
          ]
          negated: F
        )
        (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: [(C {<fail>} {(DQ <'ssh-add -l still returns keys after timeout'>)})]
              spids: [245 258]
            )
          ]
        )
        (C {<trace>} {(DQ <'kill agent'>)})
        (command.Simple
          words: [{(${ Id.VSub_Name SSHAGENT)} {<-k>}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<'/dev/null'>})]
          do_fork: T
        )
      ]
    )
  ]
)