(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:tid)
          op: assign_op.Equal
          rhs: {(DQ <scp>)}
          spids: [7]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (command.Simple
                      words: [
                        {<diff>}
                        {<-N>}
                        {(${ Id.VSub_Name SRC) <'/scp.sh'>}
                        {(${ Id.VSub_Name SRC) <'/scp.sh'>}
                      ]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '2>'>
                          loc: (redir_loc.Fd fd:2)
                          arg: {<'/dev/null'>}
                        )
                      ]
                      do_fork: T
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:DIFFOPT)
                  op: assign_op.Equal
                  rhs: {(DQ <-rN>)}
                  spids: [43]
                )
              ]
            )
          ]
          spids: [20 40]
        )
      ]
      else_action: [
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:DIFFOPT)
              op: assign_op.Equal
              rhs: {(DQ <-r>)}
              spids: [51]
            )
          ]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:COPY2)
          op: assign_op.Equal
          rhs: {(${ Id.VSub_Name OBJ) <'/copy2'>}
          spids: [59]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:DIR)
          op: assign_op.Equal
          rhs: {(${ Id.VSub_Name COPY) <.dd>}
          spids: [65]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:DIR2)
          op: assign_op.Equal
          rhs: {(${ Id.VSub_Name COPY) <.dd2>}
          spids: [71]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:SRC)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_Backtick '`'>
                child: (C {<dirname>} {(${ Id.VSub_Name SCRIPT)})
              )
            }
          spids: [78]
        )
      ]
    )
    (C {<cp>} {(${ Id.VSub_Name SRC) <'/scp-ssh-wrapper.sh'>} 
      {(${ Id.VSub_Name OBJ) <'/scp-ssh-wrapper.scp'>}
    )
    (C {<chmod>} {<755>} {(${ Id.VSub_Name OBJ) <'/scp-ssh-wrapper.scp'>})
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:scpopts)
          op: assign_op.Equal
          rhs: {(DQ <'-q -S '> (${ Id.VSub_Name OBJ) <'/scp-ssh-wrapper.scp'>)}
          spids: [110]
        )
      ]
    )
    (C {<export>} {<SCP>})
    (command.ShFunction
      name: scpclean
      body: 
        (BraceGroup
          children: [
            (C {<rm>} {<-rf>} {(${ Id.VSub_Name COPY)} {(${ Id.VSub_Name COPY2)} {(${ Id.VSub_Name DIR)} 
              {(${ Id.VSub_Name DIR2)}
            )
            (C {<mkdir>} {(${ Id.VSub_Name DIR)} {(${ Id.VSub_Name DIR2)})
          ]
        )
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': simple copy local file to local file'>)})
    (C {<scpclean>})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} {(${ Id.VSub_Name DATA)} 
          {(${ Id.VSub_Name COPY)}
        )
        (C {<fail>} {(DQ <'copy failed'>)})
      ]
    )
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {<cmp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name COPY)})
        (C {<fail>} {(DQ <'corrupted copy'>)})
      ]
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': simple copy local file to remote file'>)})
    (C {<scpclean>})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} {(${ Id.VSub_Name DATA)} 
          {<somehost> <Id.Lit_Colon ':'> (${ Id.VSub_Name COPY)}
        )
        (C {<fail>} {(DQ <'copy failed'>)})
      ]
    )
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {<cmp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name COPY)})
        (C {<fail>} {(DQ <'corrupted copy'>)})
      ]
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': simple copy remote file to local file'>)})
    (C {<scpclean>})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} 
          {<somehost> <Id.Lit_Colon ':'> (${ Id.VSub_Name DATA)} {(${ Id.VSub_Name COPY)}
        )
        (C {<fail>} {(DQ <'copy failed'>)})
      ]
    )
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {<cmp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name COPY)})
        (C {<fail>} {(DQ <'corrupted copy'>)})
      ]
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': simple copy local file to remote dir'>)})
    (C {<scpclean>})
    (C {<cp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name COPY)})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} {(${ Id.VSub_Name COPY)} 
          {<somehost> <Id.Lit_Colon ':'> (${ Id.VSub_Name DIR)}
        )
        (C {<fail>} {(DQ <'copy failed'>)})
      ]
    )
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {<cmp>} {(${ Id.VSub_Name COPY)} {(${ Id.VSub_Name DIR) <'/copy'>})
        (C {<fail>} {(DQ <'corrupted copy'>)})
      ]
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': simple copy local file to local dir'>)})
    (C {<scpclean>})
    (C {<cp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name COPY)})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} {(${ Id.VSub_Name COPY)} 
          {(${ Id.VSub_Name DIR)}
        )
        (C {<fail>} {(DQ <'copy failed'>)})
      ]
    )
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {<cmp>} {(${ Id.VSub_Name COPY)} {(${ Id.VSub_Name DIR) <'/copy'>})
        (C {<fail>} {(DQ <'corrupted copy'>)})
      ]
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': simple copy remote file to local dir'>)})
    (C {<scpclean>})
    (C {<cp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name COPY)})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} 
          {<somehost> <Id.Lit_Colon ':'> (${ Id.VSub_Name COPY)} {(${ Id.VSub_Name DIR)}
        )
        (C {<fail>} {(DQ <'copy failed'>)})
      ]
    )
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {<cmp>} {(${ Id.VSub_Name COPY)} {(${ Id.VSub_Name DIR) <'/copy'>})
        (C {<fail>} {(DQ <'corrupted copy'>)})
      ]
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': recursive local dir to remote dir'>)})
    (C {<scpclean>})
    (C {<rm>} {<-rf>} {(${ Id.VSub_Name DIR2)})
    (C {<cp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name DIR) <'/copy'>})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} {<-r>} 
          {(${ Id.VSub_Name DIR)} {<somehost> <Id.Lit_Colon ':'> (${ Id.VSub_Name DIR2)}
        )
        (C {<fail>} {(DQ <'copy failed'>)})
      ]
    )
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {<diff>} {(${ Id.VSub_Name DIFFOPT)} {(${ Id.VSub_Name DIR)} {(${ Id.VSub_Name DIR2)})
        (C {<fail>} {(DQ <'corrupted copy'>)})
      ]
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': recursive local dir to local dir'>)})
    (C {<scpclean>})
    (C {<rm>} {<-rf>} {(${ Id.VSub_Name DIR2)})
    (C {<cp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name DIR) <'/copy'>})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} {<-r>} 
          {(${ Id.VSub_Name DIR)} {(${ Id.VSub_Name DIR2)}
        )
        (C {<fail>} {(DQ <'copy failed'>)})
      ]
    )
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {<diff>} {(${ Id.VSub_Name DIFFOPT)} {(${ Id.VSub_Name DIR)} {(${ Id.VSub_Name DIR2)})
        (C {<fail>} {(DQ <'corrupted copy'>)})
      ]
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': recursive remote dir to local dir'>)})
    (C {<scpclean>})
    (C {<rm>} {<-rf>} {(${ Id.VSub_Name DIR2)})
    (C {<cp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name DIR) <'/copy'>})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} {<-r>} 
          {<somehost> <Id.Lit_Colon ':'> (${ Id.VSub_Name DIR)} {(${ Id.VSub_Name DIR2)}
        )
        (C {<fail>} {(DQ <'copy failed'>)})
      ]
    )
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (C {<diff>} {(${ Id.VSub_Name DIFFOPT)} {(${ Id.VSub_Name DIR)} {(${ Id.VSub_Name DIR2)})
        (C {<fail>} {(DQ <'corrupted copy'>)})
      ]
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': shell metacharacters'>)})
    (C {<scpclean>})
    (command.AndOr
      ops: [Id.Op_DPipe]
      children: [
        (command.Subshell
          child: 
            (command.CommandList
              children: [
                (command.Sentence
                  child: 
                    (command.AndOr
                      ops: [Id.Op_DAmp Id.Op_DAmp]
                      children: [
                        (C {<cd>} {(${ Id.VSub_Name DIR)})
                        (C {<touch>} {(SQ <'`touch metachartest`'>)})
                        (command.Simple
                          words: [
                            {($ Id.VSub_DollarName '$SCP')}
                            {($ Id.VSub_DollarName '$scpopts')}
                            {<Id.Lit_Star '*'> <metachar> <Id.Lit_Star '*'>}
                            {(${ Id.VSub_Name DIR2)}
                          ]
                          redirects: [
                            (redir
                              op: <Id.Redir_Great '2>'>
                              loc: (redir_loc.Fd fd:2)
                              arg: {<'/dev/null'>}
                            )
                          ]
                          do_fork: T
                        )
                      ]
                    )
                  terminator: <Id.Op_Semi _>
                )
                (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-f>} {<metachartest>} 
                  {<Id.Lit_RBracket ']'>}
                )
              ]
            )
        )
        (C {<fail>} {(DQ <'shell metacharacters'>)})
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-z>} 
                      {(DQ ($ Id.VSub_DollarName '$SUDO'))} {<Id.Lit_RBracket ']'>}
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (C {<verbose>} 
              {
                (DQ ($ Id.VSub_DollarName '$tid') 
                  <': skipped file after scp -p with failed chown+utimes'>
                )
              }
            )
            (C {<scpclean>})
            (C {<cp>} {<-p>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name DIR) <'/copy'>})
            (C {<cp>} {<-p>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name DIR) <'/copy2'>})
            (C {<cp>} {(${ Id.VSub_Name DATA)} {(${ Id.VSub_Name DIR2) <'/copy'>})
            (C {<chmod>} {<660>} {(${ Id.VSub_Name DIR2) <'/copy'>})
            (C {($ Id.VSub_DollarName '$SUDO')} {<chown>} {<root>} {(${ Id.VSub_Name DIR2) <'/copy'>})
            (command.Simple
              words: [
                {($ Id.VSub_DollarName '$SCP')}
                {<-p>}
                {($ Id.VSub_DollarName '$scpopts')}
                {<somehost> <Id.Lit_Colon ':'> (${ Id.VSub_Name DIR) <'/'> 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\*'>)
                }
                {(${ Id.VSub_Name DIR2)}
              ]
              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.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (C {($ Id.VSub_DollarName '$SUDO')} {<diff>} {(${ Id.VSub_Name DIFFOPT)} 
                  {(${ Id.VSub_Name DIR)} {(${ Id.VSub_Name DIR2)}
                )
                (C {<fail>} {(DQ <'corrupted copy'>)})
              ]
            )
            (C {($ Id.VSub_DollarName '$SUDO')} {<rm>} {(${ Id.VSub_Name DIR2) <'/copy'>})
          ]
          spids: [786 801]
        )
      ]
    )
    (command.ForEach
      iter_name: i
      iter_words: [{<0>} {<1>} {<2>} {<3>} {<4>}]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (C {<verbose>} 
              {
                (DQ ($ Id.VSub_DollarName '$tid') <': disallow bad server #'> 
                  ($ Id.VSub_DollarName '$i')
                )
              }
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:SCPTESTMODE)
                  op: assign_op.Equal
                  rhs: {<badserver_> ($ Id.VSub_DollarName '$i')}
                  spids: [968]
                )
              ]
            )
            (C {<export>} {<DIR>} {<SCPTESTMODE>})
            (C {<scpclean>})
            (command.Simple
              words: [
                {($ Id.VSub_DollarName '$SCP')}
                {($ Id.VSub_DollarName '$scpopts')}
                {<somehost> <Id.Lit_Colon ':'> (${ Id.VSub_Name DATA)}
                {(${ Id.VSub_Name DIR)}
              ]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {<'/dev/null'>}
                )
                (redir
                  op: <Id.Redir_Great '2>'>
                  loc: (redir_loc.Fd fd:2)
                  arg: {<'/dev/null'>}
                )
              ]
              do_fork: T
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (C {<Id.Lit_LBracket '['>} {<-d>} 
                  {<Id.Lit_LBrace '{'> ($ Id.VSub_DollarName '$DIR') <Id.Lit_RBrace '}'> 
                    <'/rootpathdir'>
                  } {<Id.Lit_RBracket ']'>}
                )
                (C {<fail>} {(DQ <'allows dir relative to root dir'>)})
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (C {<Id.Lit_LBracket '['>} {<-d>} {(${ Id.VSub_Name DIR) <'/dotpathdir'>} 
                  {<Id.Lit_RBracket ']'>}
                )
                (C {<fail>} {(DQ <'allows dir creation in non-recursive mode'>)})
              ]
            )
            (C {<scpclean>})
            (command.Simple
              words: [
                {($ Id.VSub_DollarName '$SCP')}
                {<-r>}
                {($ Id.VSub_DollarName '$scpopts')}
                {<somehost> <Id.Lit_Colon ':'> (${ Id.VSub_Name DATA)}
                {(${ Id.VSub_Name DIR2)}
              ]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {<'/dev/null'>}
                )
                (redir
                  op: <Id.Redir_Great '2>'>
                  loc: (redir_loc.Fd fd:2)
                  arg: {<'/dev/null'>}
                )
              ]
              do_fork: T
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (C {<Id.Lit_LBracket '['>} {<-d>} {(${ Id.VSub_Name DIR) <'/dotpathdir'>} 
                  {<Id.Lit_RBracket ']'>}
                )
                (C {<fail>} {(DQ <'allows dir creation outside of subdir'>)})
              ]
            )
          ]
        )
    )
    (C {<verbose>} {(DQ ($ Id.VSub_DollarName '$tid') <': detect non-directory target'>)})
    (C {<scpclean>})
    (command.Simple
      words: [{<echo>} {<a>}]
      redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{(${ Id.VSub_Name COPY)})]
      do_fork: T
    )
    (command.Simple
      words: [{<echo>} {<b>}]
      redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{(${ Id.VSub_Name COPY2)})]
      do_fork: T
    )
    (C {($ Id.VSub_DollarName '$SCP')} {($ Id.VSub_DollarName '$scpopts')} {(${ Id.VSub_Name DATA)} 
      {(${ Id.VSub_Name COPY)} {(${ Id.VSub_Name COPY2)}
    )
    (command.AndOr
      ops: [Id.Op_DAmp]
      children: [
        (command.Simple
          words: [{<cmp>} {(${ Id.VSub_Name COPY)} {(${ Id.VSub_Name COPY2)}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<'/dev/null'>})]
          do_fork: T
        )
        (C {<fail>} {(DQ <'corrupt target'>)})
      ]
    )
    (C {<scpclean>})
    (C {<rm>} {<-f>} {(${ Id.VSub_Name OBJ) <'/scp-ssh-wrapper.scp'>})
  ]
)