(CommandList
  children: [
    (FuncDef
      name: fail_test
      body: 
        (BraceGroup
          children: [
            (C {(echo)} {(DQ ("FAILED: ") ($ VSub_Number "$1"))})
            (C {(rm)} {(-rf)} {(DQ ($ VSub_Name "$ASDF_DIR"))})
            (C {(exit)} {(1)})
          ]
          spids: [4]
        )
      spids: [0 3]
    )
    (FuncDef
      name: plugin_test_command
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:ASDF_DIR)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: (CommandList children:[(C {(mktemp)} {(-dt)} {(asdf.XXXX)})])
                        left_token: <Left_CommandSub "$(">
                        spids: [39 45]
                      )
                    }
                  spids: [38]
                )
              ]
              spids: [38]
            )
            (C {(export)} {(ASDF_DIR)})
            (C {(git)} {(clone)} {(https) (Lit_Other ":") (//github.com/asdf-vm/asdf.git)} 
              {(DQ ($ VSub_Name "$ASDF_DIR"))}
            )
            (Assignment
              keyword: Assign_Local
              pairs: [
                (assign_pair
                  lhs: (LhsName name:plugin_name)
                  op: Equal
                  rhs: {($ VSub_Number "$1")}
                  spids: [69]
                )
              ]
              spids: [67]
            )
            (Assignment
              keyword: Assign_Local
              pairs: [
                (assign_pair
                  lhs: (LhsName name:plugin_url)
                  op: Equal
                  rhs: {($ VSub_Number "$2")}
                  spids: [75]
                )
              ]
              spids: [73]
            )
            (Assignment
              keyword: Assign_Local
              pairs: [
                (assign_pair
                  lhs: (LhsName name:plugin_command)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (BracedVarSub
                          token: <VSub_Star "*">
                          suffix_op: (Slice begin:(ArithWord w:{(Lit_Digits 3)}))
                          spids: [83 87]
                        )
                      )
                    }
                  spids: [81]
                )
              ]
              spids: [79]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (AndOr
                          children: [
                            (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$plugin_name"))} 
                              {(Lit_Other "]")}
                            )
                            (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$plugin_url"))} 
                              {(Lit_Other "]")}
                            )
                          ]
                          op_id: Op_DPipe
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(fail_test)} {(DQ ("please provide a plugin name and url"))})]
                  spids: [-1 117]
                )
              ]
              spids: [-1 127]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (Pipeline
                          children: [
                            (Subshell
                              child: 
                                (C {(asdf)} {(plugin-add)} {(DQ ($ VSub_Name "$plugin_name"))} 
                                  {(DQ ($ VSub_Name "$plugin_url"))}
                                )
                              spids: [135 147]
                            )
                          ]
                          negated: True
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (C {(fail_test)} 
                      {
                        (DQ ("could not install ") ($ VSub_Name "$plugin_name") (" from ") 
                          ($ VSub_Name "$plugin_url")
                        )
                      }
                    )
                  ]
                  spids: [-1 150]
                )
              ]
              spids: [-1 163]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (Pipeline
                          children: [
                            (Subshell
                              child: 
                                (Pipeline
                                  children: [
                                    (C {(asdf)} {(plugin-list)})
                                    (SimpleCommand
                                      words: [{(grep)} {(DQ ($ VSub_Name "$plugin_name"))}]
                                      redirects: [
                                        (Redir
                                          op_id: Redir_Great
                                          fd: -1
                                          arg_word: {(/dev/null)}
                                          spids: [184]
                                        )
                                      ]
                                    )
                                  ]
                                  negated: False
                                )
                              spids: [171 187]
                            )
                          ]
                          negated: True
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (C {(fail_test)} {(DQ ($ VSub_Name "$plugin_name") (" was not properly installed"))})
                  ]
                  spids: [-1 190]
                )
              ]
              spids: [-1 201]
            )
            (Assignment
              keyword: Assign_Local
              pairs: [(assign_pair lhs:(LhsName name:versions) op:Equal spids:[207])]
              spids: [205]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (Pipeline
                          children: [
                            (SimpleCommand
                              words: [{(read)} {(-r)} {(-a)} {(versions)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_TLess
                                  fd: -1
                                  arg_word: 
                                    {
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [
                                              (C {(asdf)} {(list-all)} 
                                                {(DQ ($ VSub_Name "$plugin_name"))}
                                              )
                                            ]
                                          )
                                        left_token: <Left_CommandSub "$(">
                                        spids: [228 236]
                                      )
                                    }
                                  spids: [226]
                                )
                              ]
                            )
                          ]
                          negated: True
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(fail_test)} {(DQ ("list-all exited with an error"))})]
                  spids: [-1 239]
                )
              ]
              spids: [-1 249]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} 
                          {
                            (BracedVarSub
                              token: <VSub_Name versions>
                              prefix_op: VSub_Pound
                              spids: [257 260]
                            )
                          } {(-eq)} {(0)} {(Lit_Other "]")}
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(fail_test)} {(DQ ("list-all did not return any version"))})]
                  spids: [-1 269]
                )
              ]
              spids: [-1 279]
            )
            (Assignment
              keyword: Assign_Local
              pairs: [(assign_pair lhs:(LhsName name:latest_version) op:Equal spids:[285])]
              spids: [283]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:latest_version)
                  op: Equal
                  rhs: 
                    {
                      (BracedVarSub
                        token: <VSub_Name versions>
                        bracket_op: 
                          (ArrayIndex
                            expr: 
                              (ArithBinary
                                op_id: Arith_Minus
                                left: 
                                  (ArithWord
                                    w: 
                                      {
                                        (BracedVarSub
                                          token: <VSub_Name versions>
                                          prefix_op: VSub_Pound
                                          bracket_op: (WholeArray op_id:Lit_At)
                                          spids: [292 298]
                                        )
                                      }
                                  )
                                right: (ArithWord w:{(Lit_Digits 1)})
                              )
                          )
                        spids: [289 304]
                      )
                    }
                  spids: [288]
                )
              ]
              spids: [288]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (Pipeline
                          children: [
                            (Subshell
                              child: 
                                (C {(asdf)} {(install)} {(DQ ($ VSub_Name "$plugin_name"))} 
                                  {(DQ ($ VSub_Name "$latest_version"))}
                                )
                              spids: [312 324]
                            )
                          ]
                          negated: True
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(fail_test)} {(DQ ("install exited with an error"))})]
                  spids: [-1 327]
                )
              ]
              spids: [-1 337]
            )
            (AndOr
              children: [
                (C {(cd)} {(DQ ($ VSub_Name "$ASDF_DIR"))})
                (C {(fail_test)} {(DQ ("could not cd ") ($ VSub_Name "$ASDF_DIR"))})
              ]
              op_id: Op_DPipe
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (Pipeline
                          children: [
                            (Subshell
                              child: 
                                (C {(asdf)} {(Assign_Local local)} {(DQ ($ VSub_Name "$plugin_name"))} 
                                  {(DQ ($ VSub_Name "$latest_version"))}
                                )
                              spids: [362 374]
                            )
                          ]
                          negated: True
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(fail_test)} {(DQ ("install did not add the requested version"))})]
                  spids: [-1 377]
                )
              ]
              spids: [-1 387]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (Pipeline
                          children: [
                            (Subshell
                              child: (C {(asdf)} {(reshim)} {(DQ ($ VSub_Name "$plugin_name"))})
                              spids: [395 403]
                            )
                          ]
                          negated: True
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(fail_test)} {(DQ ("could not reshim plugin"))})]
                  spids: [-1 406]
                )
              ]
              spids: [-1 416]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} {(-n)} {(DQ ($ VSub_Name "$plugin_command"))} 
                          {(Lit_Other "]")}
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (Subshell
                      child: 
                        (SimpleCommand
                          words: [{(eval)} {(DQ ($ VSub_Name "$plugin_command"))}]
                          more_env: [
                            (env_pair
                              name: PATH
                              val: 
                                {
                                  (DQ ($ VSub_Name "$ASDF_DIR") ("/bin:") ($ VSub_Name "$ASDF_DIR") 
                                    ("/shims:") ($ VSub_Name "$PATH")
                                  )
                                }
                              spids: [437]
                            )
                          ]
                        )
                      spids: [436 451]
                    )
                    (Assignment
                      keyword: Assign_Local
                      pairs: [(assign_pair lhs:(LhsName name:exit_code) op:Equal spids:[456])]
                      spids: [454]
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:exit_code)
                          op: Equal
                          rhs: {($ VSub_QMark "$?")}
                          spids: [459]
                        )
                      ]
                      spids: [459]
                    )
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other "[")} {($ VSub_Name "$exit_code")} 
                                  {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")}
                                )
                              terminator: <Op_Semi ";">
                            )
                          ]
                          action: [
                            (C {(fail_test)} 
                              {
                                (DQ ($ VSub_Name "$plugin_command") (" failed with exit code ") 
                                  ($ VSub_QMark "$?")
                                )
                              }
                            )
                          ]
                          spids: [-1 477]
                        )
                      ]
                      spids: [-1 489]
                    )
                  ]
                  spids: [-1 433]
                )
              ]
              spids: [-1 492]
            )
            (ForEach
              iter_name: filename
              iter_words: [
                {(DQ ($ VSub_Name "$ASDF_DIR") (/plugins/) ($ VSub_Name "$plugin_name") (/bin)) (/) 
                  (Lit_Other "*")
                }
              ]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other "[")} {(KW_Bang "!")} {(-x)} 
                                  {(DQ ($ VSub_Name "$filename"))} {(Lit_Other "]")}
                                )
                              terminator: <Op_Semi ";">
                            )
                          ]
                          action: [
                            (C {(fail_test)} 
                              {
                                (DQ ("Incorrect permissions on ") ($ VSub_Name "$filename") 
                                  (". Must be executable by asdf")
                                )
                              }
                            )
                          ]
                          spids: [-1 534]
                        )
                      ]
                      spids: [-1 546]
                    )
                  ]
                  spids: [516 549]
                )
              spids: [505 -1]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:license_file)
                  op: Equal
                  rhs: 
                    {
                      (DQ ($ VSub_Name "$ASDF_DIR") (/plugins/) ($ VSub_Name "$plugin_name") (/LICENSE))
                    }
                  spids: [557]
                )
              ]
              spids: [557]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} {(-f)} {(DQ ($ VSub_Name "$license_file"))} 
                          {(Lit_Other "]")}
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other "[")} {(KW_Bang "!")} {(-s)} 
                                  {(DQ ($ VSub_Name "$license_file"))} {(Lit_Other "]")}
                                )
                              terminator: <Op_Semi ";">
                            )
                          ]
                          action: [
                            (C {(fail_test)} 
                              {(DQ ("LICENSE file in the plugin repository must not be empty"))}
                            )
                          ]
                          spids: [-1 597]
                        )
                      ]
                      spids: [-1 607]
                    )
                  ]
                  spids: [-1 579]
                )
              ]
              else_action: [
                (C {(fail_test)} {(DQ ("LICENSE file must be present in the plugin repository"))})
              ]
              spids: [610 620]
            )
            (C {(rm)} {(-rf)} {(DQ ($ VSub_Name "$ASDF_DIR"))})
          ]
          spids: [35]
        )
      spids: [31 34]
    )
  ]
)