(CommandList
  children: [
    (FuncDef
      name: handle_failure
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_Local
              pairs: [
                (assign_pair
                  lhs: (LhsName name:install_path)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number "$1"))}
                  spids: [9]
                )
              ]
              spids: [7]
            )
            (C {(rm)} {(-rf)} {(DQ ($ VSub_Name "$install_path"))})
            (C {(exit)} {(1)})
          ]
          spids: [4]
        )
      spids: [0 3]
    )
    (FuncDef
      name: handle_cancel
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_Local
              pairs: [
                (assign_pair
                  lhs: (LhsName name:install_path)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number "$1"))}
                  spids: [40]
                )
              ]
              spids: [38]
            )
            (C {(echo)} {(-e)} 
              {
                (DQ (EscapedLiteralPart token:<Lit_EscapedChar "\\n">) 
                  ("received sigint, cleaning up")
                )
              }
            )
            (C {(handle_failure)} {(DQ ($ VSub_Name "$install_path"))})
          ]
          spids: [35]
        )
      spids: [31 34]
    )
    (FuncDef
      name: install_command
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_Local
              pairs: [
                (assign_pair
                  lhs: (LhsName name:plugin_name)
                  op: Equal
                  rhs: {($ VSub_Number "$1")}
                  spids: [74]
                )
              ]
              spids: [72]
            )
            (Assignment
              keyword: Assign_Local
              pairs: [
                (assign_pair
                  lhs: (LhsName name:full_version)
                  op: Equal
                  rhs: {($ VSub_Number "$2")}
                  spids: [80]
                )
              ]
              spids: [78]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (AndOr
                          children: [
                            (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$plugin_name"))} {(Lit_Other "=")} {(DQ )} 
                              {(Lit_Other "]")}
                            )
                            (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$full_version"))} {(Lit_Other "=")} {(DQ )} 
                              {(Lit_Other "]")}
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(install_local_tool_versions)})]
                  spids: [-1 116]
                )
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (DBracket
                          expr: (BoolBinary op_id:BoolBinary_eq left:{($ VSub_Pound "$#")} right:{(1)})
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (C {(display_error)} {(DQ ("You must specify a name and a version to install"))})
                    (C {(exit)} {(1)})
                  ]
                  spids: [122 135]
                )
              ]
              else_action: [
                (C {(install_tool_version)} {(DQ ($ VSub_Name "$plugin_name"))} 
                  {(DQ ($ VSub_Name "$full_version"))}
                )
              ]
              spids: [150 164]
            )
          ]
          spids: [69]
        )
      spids: [65 68]
    )
    (FuncDef
      name: get_concurrency
      body: 
        (BraceGroup
          children: [
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (SimpleCommand
                          words: [{(which)} {(nproc)}]
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: -1
                              arg_word: {(/dev/null)}
                              spids: [182]
                            )
                            (Redir
                              op_id: Redir_GreatAnd
                              fd: 2
                              arg_word: {(1)}
                              spids: [186]
                            )
                          ]
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(nproc)})]
                  spids: [-1 190]
                )
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (AndOr
                          children: [
                            (SimpleCommand
                              words: [{(which)} {(sysctl)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Great
                                  fd: -1
                                  arg_word: {(/dev/null)}
                                  spids: [202]
                                )
                                (Redir
                                  op_id: Redir_GreatAnd
                                  fd: 2
                                  arg_word: {(1)}
                                  spids: [206]
                                )
                              ]
                            )
                            (SimpleCommand
                              words: [{(sysctl)} {(hw.ncpu)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Great
                                  fd: -1
                                  arg_word: {(/dev/null)}
                                  spids: [215]
                                )
                                (Redir
                                  op_id: Redir_GreatAnd
                                  fd: 2
                                  arg_word: {(1)}
                                  spids: [219]
                                )
                              ]
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(sysctl)} {(-n)} {(hw.ncpu)})]
                  spids: [196 223]
                )
                (if_arm
                  cond: [
                    (Sentence
                      child: (C {(Lit_Other "[")} {(-f)} {(/proc/cpuinfo)} {(Lit_Other "]")})
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [(C {(grep)} {(-c)} {(processor)} {(/proc/cpuinfo)})]
                  spids: [233 244]
                )
              ]
              else_action: [(C {(echo)} {(DQ (1))})]
              spids: [256 266]
            )
          ]
          spids: [173]
        )
      spids: [169 172]
    )
    (FuncDef
      name: install_local_tool_versions
      body: 
        (BraceGroup
          children: [
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} {(-f)} 
                          {
                            (DQ 
                              (CommandSubPart
                                command_list: (CommandList children:[(C {(pwd)})])
                                left_token: <Left_CommandSub "$(">
                                spids: [285 287]
                              ) (/.tool-versions)
                            )
                          } {(Lit_Other "]")}
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (Assignment
                      keyword: Assign_Local
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:asdf_versions_path)
                          op: Equal
                          spids: [299]
                        )
                      ]
                      spids: [297]
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:asdf_versions_path)
                          op: Equal
                          rhs: 
                            {
                              (DQ 
                                (CommandSubPart
                                  command_list: (CommandList children:[(C {(pwd)})])
                                  left_token: <Left_CommandSub "$(">
                                  spids: [304 306]
                                ) (/.tool-versions)
                              )
                            }
                          spids: [302]
                        )
                      ]
                      spids: [302]
                    )
                    (While
                      cond: [
                        (Sentence
                          child: (C {(read)} {(-r)} {(tool_line)})
                          terminator: <Op_Semi ";">
                        )
                      ]
                      body: 
                        (DoGroup
                          children: [
                            (SimpleCommand
                              words: [{(read)} {(-r)} {(-a)} {(tool_info)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_TLess
                                  fd: -1
                                  arg_word: {(DQ ($ VSub_Name "$tool_line"))}
                                  spids: [337]
                                )
                              ]
                              more_env: [(env_pair name:IFS val:{(SQ <" ">)} spids:[324])]
                            )
                            (Assignment
                              keyword: Assign_Local
                              pairs: [(assign_pair lhs:(LhsName name:tool_name) op:Equal spids:[346])]
                              spids: [344]
                            )
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:tool_name)
                                  op: Equal
                                  rhs: 
                                    {
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [
                                              (Pipeline
                                                children: [
                                                  (C {(echo)} 
                                                    {
                                                      (DQ 
                                                        (BracedVarSub
                                                          token: <VSub_Name tool_info>
                                                          bracket_op: 
                                                            (ArrayIndex
                                                              expr: (ArithWord w:{(Lit_Digits 0)})
                                                            )
                                                          spids: [354 359]
                                                        )
                                                      )
                                                    }
                                                  )
                                                  (C {(xargs)})
                                                ]
                                                negated: False
                                              )
                                            ]
                                          )
                                        left_token: <Left_CommandSub "$(">
                                        spids: [350 365]
                                      )
                                    }
                                  spids: [349]
                                )
                              ]
                              spids: [349]
                            )
                            (Assignment
                              keyword: Assign_Local
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:tool_version)
                                  op: Equal
                                  spids: [370]
                                )
                              ]
                              spids: [368]
                            )
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:tool_version)
                                  op: Equal
                                  rhs: 
                                    {
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [
                                              (Pipeline
                                                children: [
                                                  (C {(echo)} 
                                                    {
                                                      (DQ 
                                                        (BracedVarSub
                                                          token: <VSub_Name tool_info>
                                                          bracket_op: 
                                                            (ArrayIndex
                                                              expr: (ArithWord w:{(Lit_Digits 1)})
                                                            )
                                                          spids: [378 383]
                                                        )
                                                      )
                                                    }
                                                  )
                                                  (C {(xargs)})
                                                ]
                                                negated: False
                                              )
                                            ]
                                          )
                                        left_token: <Left_CommandSub "$(">
                                        spids: [374 389]
                                      )
                                    }
                                  spids: [373]
                                )
                              ]
                              spids: [373]
                            )
                            (If
                              arms: [
                                (if_arm
                                  cond: [
                                    (Sentence
                                      child: 
                                        (Pipeline
                                          children: [
                                            (DBracket
                                              expr: 
                                                (LogicalOr
                                                  left: 
                                                    (BoolUnary
                                                      op_id: BoolUnary_z
                                                      child: {(DQ ($ VSub_Name "$tool_name"))}
                                                    )
                                                  right: 
                                                    (BoolUnary
                                                      op_id: BoolUnary_z
                                                      child: {(DQ ($ VSub_Name "$tool_version"))}
                                                    )
                                                )
                                            )
                                          ]
                                          negated: True
                                        )
                                      terminator: <Op_Semi ";">
                                    )
                                  ]
                                  action: [
                                    (C {(install_tool_version)} {(DQ ($ VSub_Name "$tool_name"))} 
                                      {(DQ ($ VSub_Name "$tool_version"))}
                                    )
                                  ]
                                  spids: [-1 416]
                                )
                              ]
                              spids: [-1 430]
                            )
                          ]
                          spids: [321 433]
                        )
                      redirects: [
                        (Redir
                          op_id: Redir_Less
                          fd: -1
                          arg_word: {(DQ ($ VSub_Name "$asdf_versions_path"))}
                          spids: [435]
                        )
                      ]
                    )
                  ]
                  spids: [-1 294]
                )
              ]
              else_action: [
                (C {(echo)} {(DQ ("Either specify a tool & version in the command"))})
                (C {(echo)} {(DQ ("OR add .tool-versions file in this directory"))})
                (C {(exit)} {(1)})
              ]
              spids: [442 464]
            )
          ]
          spids: [275]
        )
      spids: [271 274]
    )
    (FuncDef
      name: install_tool_version
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_Local
              pairs: [
                (assign_pair
                  lhs: (LhsName name:plugin_name)
                  op: Equal
                  rhs: {($ VSub_Number "$1")}
                  spids: [479]
                )
              ]
              spids: [477]
            )
            (Assignment
              keyword: Assign_Local
              pairs: [
                (assign_pair
                  lhs: (LhsName name:full_version)
                  op: Equal
                  rhs: {($ VSub_Number "$2")}
                  spids: [485]
                )
              ]
              spids: [483]
            )
            (Assignment
              keyword: Assign_Local
              pairs: [(assign_pair lhs:(LhsName name:plugin_path) op:Equal spids:[491])]
              spids: [489]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:plugin_path)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [(C {(get_plugin_path)} {(DQ ($ VSub_Name "$plugin_name"))})]
                          )
                        left_token: <Left_CommandSub "$(">
                        spids: [495 501]
                      )
                    }
                  spids: [494]
                )
              ]
              spids: [494]
            )
            (C {(check_if_plugin_exists)} {(DQ ($ VSub_Name "$plugin_name"))})
            (SimpleCommand
              words: [{(read)} {(-r)} {(-a)} {(version_info)}]
              redirects: [
                (Redir
                  op_id: Redir_TLess
                  fd: -1
                  arg_word: {(DQ ($ VSub_Name "$full_version"))}
                  spids: [526]
                )
              ]
              more_env: [(env_pair name:IFS val:{(SQ <":">)} spids:[513])]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} 
                          {
                            (DQ 
                              (BracedVarSub
                                token: <VSub_Name version_info>
                                bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 0)}))
                                spids: [538 543]
                              )
                            )
                          } {(Lit_Other "=")} {(DQ (ref))} {(Lit_Other "]")}
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (Assignment
                      keyword: Assign_Local
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:install_type)
                          op: Equal
                          rhs: 
                            {
                              (DQ 
                                (BracedVarSub
                                  token: <VSub_Name version_info>
                                  bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 0)}))
                                  spids: [562 567]
                                )
                              )
                            }
                          spids: [560]
                        )
                      ]
                      spids: [558]
                    )
                    (Assignment
                      keyword: Assign_Local
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:version)
                          op: Equal
                          rhs: 
                            {
                              (DQ 
                                (BracedVarSub
                                  token: <VSub_Name version_info>
                                  bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 1)}))
                                  spids: [575 580]
                                )
                              )
                            }
                          spids: [573]
                        )
                      ]
                      spids: [571]
                    )
                  ]
                  spids: [-1 555]
                )
              ]
              else_action: [
                (Assignment
                  keyword: Assign_Local
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:install_type)
                      op: Equal
                      rhs: {(DQ (version))}
                      spids: [589]
                    )
                  ]
                  spids: [587]
                )
                (Assignment
                  keyword: Assign_Local
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:version)
                      op: Equal
                      rhs: 
                        {
                          (DQ 
                            (BracedVarSub
                              token: <VSub_Name version_info>
                              bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 0)}))
                              spids: [599 604]
                            )
                          )
                        }
                      spids: [597]
                    )
                  ]
                  spids: [595]
                )
              ]
              spids: [584 608]
            )
            (Assignment
              keyword: Assign_Local
              pairs: [(assign_pair lhs:(LhsName name:install_path) op:Equal spids:[615])]
              spids: [613]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:install_path)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [
                              (C {(get_install_path)} {(DQ ($ VSub_Name "$plugin_name"))} 
                                {(DQ ($ VSub_Name "$install_type"))} {(DQ ($ VSub_Name "$version"))}
                              )
                            ]
                          )
                        left_token: <Left_CommandSub "$(">
                        spids: [619 633]
                      )
                    }
                  spids: [618]
                )
              ]
              spids: [618]
            )
            (Assignment
              keyword: Assign_Local
              pairs: [(assign_pair lhs:(LhsName name:concurrency) op:Equal spids:[638])]
              spids: [636]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:concurrency)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: (CommandList children:[(C {(get_concurrency)})])
                        left_token: <Left_CommandSub "$(">
                        spids: [642 644]
                      )
                    }
                  spids: [641]
                )
              ]
              spids: [641]
            )
            (C {(trap)} {(SQ <"handle_cancel $install_path">)} {(INT)})
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other "[")} {(-d)} {(DQ ($ VSub_Name "$install_path"))} 
                          {(Lit_Other "]")}
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (C {(echo)} 
                      {
                        (DQ ($ VSub_Name "$plugin_name") (" ") ($ VSub_Name "$full_version") 
                          (" is already installed")
                        )
                      }
                    )
                  ]
                  spids: [-1 670]
                )
              ]
              else_action: [
                (Subshell
                  child: 
                    (CommandList
                      children: [
                        (C {(export)} 
                          {(Lit_VarLike "ASDF_INSTALL_TYPE=") ($ VSub_Name "$install_type")}
                        )
                        (C {(export)} {(Lit_VarLike "ASDF_INSTALL_VERSION=") ($ VSub_Name "$version")})
                        (C {(export)} 
                          {(Lit_VarLike "ASDF_INSTALL_PATH=") ($ VSub_Name "$install_path")}
                        )
                        (C {(export)} {(Lit_VarLike "ASDF_CONCURRENCY=") ($ VSub_Name "$concurrency")})
                        (C {(mkdir)} {(DQ ($ VSub_Name "$install_path"))})
                        (C {(bash)} {(DQ (${ VSub_Name plugin_path)) (/bin/install)})
                      ]
                    )
                  spids: [686 730]
                )
                (Assignment
                  keyword: Assign_Local
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:exit_code)
                      op: Equal
                      rhs: {($ VSub_QMark "$?")}
                      spids: [736]
                    )
                  ]
                  spids: [734]
                )
                (If
                  arms: [
                    (if_arm
                      cond: [
                        (Sentence
                          child: 
                            (C {(Lit_Other "[")} {($ VSub_Name "$exit_code")} {(-eq)} {(0)} 
                              {(Lit_Other "]")}
                            )
                          terminator: <Op_Semi ";">
                        )
                      ]
                      action: [
                        (C {(reshim_command)} {(DQ ($ VSub_Name "$plugin_name"))} 
                          {(DQ ($ VSub_Name "$full_version"))}
                        )
                      ]
                      spids: [-1 753]
                    )
                  ]
                  else_action: [(C {(handle_failure)} {(DQ ($ VSub_Name "$install_path"))})]
                  spids: [767 777]
                )
              ]
              spids: [683 780]
            )
          ]
          spids: [474]
        )
      spids: [470 473]
    )
  ]
)