(command.CommandList
  children: [
    (C {(hash)} {(-r)})
    (command.ShFunction
      name: wait_for_ssh
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(Id.Lit_VarLike 'hostname=') (DQ ($ Id.VSub_Number '$1'))})
            (C {(local)} 
              {(Id.Lit_VarLike 'min=') 
                (braced_var_sub
                  token: (Token id:Id.VSub_Number val:2 span_id:35)
                  suffix_op: (suffix_op.Unary op_id:Id.VTest_ColonHyphen arg_word:{(1)})
                )
              } 
              {(Id.Lit_VarLike 'max=') 
                (braced_var_sub
                  token: (Token id:Id.VSub_Number val:3 span_id:42)
                  suffix_op: (suffix_op.Unary op_id:Id.VTest_ColonHyphen arg_word:{(10)})
                )
              }
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Id.Lit_LBracket '[')} {(-z)} {(DQ (${ Id.VSub_Name hostname))} 
                          {(Id.Lit_RBracket ']')}
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:63)
                    )
                  ]
                  action: [
                    (command.Sentence
                      child: 
                        (command.ControlFlow
                          token: (Token id:Id.ControlFlow_Return val:return span_id:67)
                          arg_word: {(1)}
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:71)
                    )
                  ]
                  spids: [49 65]
                )
              ]
            )
            (command.Simple
              words: [{(exec)}]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_GreatAnd val:'3>&' span_id:78)
                  fd: 3
                  arg_word: {(2)}
                )
              ]
            )
            (command.Simple
              words: [{(exec)}]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_Great val:'2>' span_id:84)
                  fd: 2
                  arg_word: {(/dev/null)}
                )
              ]
            )
            (command.WhileUntil
              keyword: (Token id:Id.KW_While val:while span_id:88)
              cond: [
                (command.Sentence
                  child: (C {(true)})
                  terminator: (Token id:Id.Op_Semi val:';' span_id:92)
                )
              ]
              body: 
                (command.DoGroup
                  children: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (command.Simple
                                  words: [{(echo)}]
                                  redirects: [
                                    (redir.Redir
                                      op: (Token id:Id.Redir_Great val:'>' span_id:101)
                                      fd: -1
                                      arg_word: {(/dev/tcp/) (${ Id.VSub_Name hostname) (/22)}
                                    )
                                  ]
                                )
                              terminator: (Token id:Id.Op_Semi val:';' span_id:109)
                            )
                          ]
                          action: [
                            (command.ControlFlow
                              token: (Token id:Id.ControlFlow_Return val:return span_id:114)
                              arg_word: {(0)}
                            )
                          ]
                          spids: [97 111]
                        )
                      ]
                    )
                    (C {(sleep)} 
                      {
                        (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 '$max')})
                                )
                              right: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$min')})
                            )
                        )
                      }
                    )
                  ]
                )
            )
            (command.Simple
              words: [{(exec)}]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_GreatAnd val:'2>&' span_id:145)
                  fd: 2
                  arg_word: {(3)}
                )
              ]
            )
            (command.Simple
              words: [{(exec)}]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_GreatAnd val:'3>&' span_id:151)
                  fd: 3
                  arg_word: {(-)}
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: wait_for_snapshot
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(Id.Lit_VarLike 'ip=') (DQ ($ Id.VSub_Number '$1'))})
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Id.Lit_LBracket '[')} {(-z)} {(DQ (${ Id.VSub_Name ip))} 
                          {(Id.Lit_RBracket ']')}
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:185)
                    )
                  ]
                  action: [
                    (command.ControlFlow
                      token: (Token id:Id.ControlFlow_Return val:return span_id:190)
                      arg_word: {(1)}
                    )
                  ]
                  spids: [171 187]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (C {(local)} 
                  {(Id.Lit_VarLike 'vmname=') 
                    (DQ 
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:202)
                        command_list: 
                          (command.CommandList
                            children: [(C {(ip_to_name)} {(${ Id.VSub_Name ip)})]
                          )
                      )
                    )
                  }
                )
                (command.ControlFlow
                  token: (Token id:Id.ControlFlow_Return val:return span_id:213)
                  arg_word: {(2)}
                )
              ]
            )
            (C {(echo)} 
              {
                (DQ ('Waiting to snapshot ') (${ Id.VSub_Name vmname) (' at ') (${ Id.VSub_Name ip) (...))
              }
            )
            (C {(wait_for_ssh)} {(DQ (${ Id.VSub_Name ip))})
            (C {(VBoxManage)} {(snapshot)} {(DQ (${ Id.VSub_Name vmname))} {(take)} {(build_completed)} 
              {(--description)} {(DQ ('Base OS installed'))}
            )
          ]
        )
    )
    (command.ShFunction
      name: ip_to_name
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Id.Lit_LBracket '[')} {(-z)} {(DQ ($ Id.VSub_Number '$1'))} 
                          {(Id.Lit_RBracket ']')}
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:286)
                    )
                  ]
                  action: [
                    (command.Sentence
                      child: 
                        (command.ControlFlow
                          token: (Token id:Id.ControlFlow_Return val:return span_id:290)
                          arg_word: {(1)}
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:294)
                    )
                  ]
                  spids: [274 288]
                )
              ]
            )
            (C {(local)} 
              {(Id.Lit_VarLike 'l=') 
                (DQ 
                  (braced_var_sub
                    token: (Token id:Id.VSub_Number val:1 span_id:304)
                    suffix_op: (suffix_op.Unary op_id:Id.VOp1_DPound arg_word:{('*.')})
                  )
                )
              }
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:l)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (word_part.ArithSub
                        anode: 
                          (arith_expr.Binary
                            op_id: Id.Arith_Minus
                            left: 
                              (arith_expr.VarRef
                                token: (Token id:Id.Lit_ArithVarLike val:l span_id:313)
                              )
                            right: (arith_expr.ArithWord w:{(Id.Lit_Digits 10)})
                          )
                      )
                    }
                  spids: [311]
                )
              ]
            )
            (C {(echo)} {(DQ (bcpc-vm) (${ Id.VSub_Name l))})
          ]
        )
    )
    (command.ForEach
      iter_name: ip
      iter_words: [
        (word.BracedTree
          parts: [(10.0.100.) (word_part.BracedRange kind:Id.Range_Int start:11 end:13 step:1)]
        )
      ]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.Sentence
              child: (C {(eval)} {(DQ ('wait_for_snapshot ') (${ Id.VSub_Name ip) (' &'))})
              terminator: (Token id:Id.Op_Semi val:';' span_id:357)
            )
          ]
        )
    )
    (C {(wait)})
  ]
)