(command.CommandList
  children: [
    (C {<set>} {<-o>} {<nounset>})
    (C {<set>} {<-o>} {<pipefail>})
    (C {<set>} {<-o>} {<errexit>})
    (command.ShFunction
      name: change-kind
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'kind='> ($ Id.VSub_Number '$1')})
            (C {<local>} 
              {<Id.Lit_VarLike 'kind2='> 
                (braced_var_sub
                  token: <Id.VSub_Number 2>
                  suffix_op: 
                    (suffix_op.Unary
                      tok: <Id.VTest_ColonHyphen ':-'>
                      arg_word: {($ Id.VSub_DollarName '$kind')}
                    )
                )
              }
            )
            (C {<sed>} {<-r>} {<-i>} 
              {
                (DQ <'s/'> (${ Id.VSub_Name kind) <'_([A-Z]+)/Id.'> (${ Id.VSub_Name kind2) <_> 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) <L> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) <'1/g'>
                )
              } {<Id.Lit_Star '*'> <'/'> <Id.Lit_Star '*'> <.py>}
            )
            (C {<sed>} {<-r>} {<-i>} 
              {
                (DQ <'s/'> (${ Id.VSub_Name kind) <'_([a-zA-Z]+)/'> (${ Id.VSub_Name kind2) <_> 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) <u> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\\'>) <'1/g'>
                )
              } {<Id.Lit_Star '*'> <'/'> <Id.Lit_Star '*'> <.py>}
            )
          ]
        )
    )
    (command.ShFunction
      name: k2
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'kind='> ($ Id.VSub_Number '$1')})
            (C {<local>} 
              {<Id.Lit_VarLike 'lower='> 
                (braced_var_sub
                  token: <Id.VSub_Name kind>
                  suffix_op: (suffix_op.Unary tok:<Id.VOp1_DComma ',,'> arg_word:{})
                )
              }
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'title='> 
                (braced_var_sub
                  token: <Id.VSub_Name lower>
                  suffix_op: (suffix_op.Unary tok:<Id.VOp1_Caret '^'> arg_word:{})
                )
              }
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'replace='> 
                (braced_var_sub
                  token: <Id.VSub_Number 2>
                  suffix_op: 
                    (suffix_op.Unary
                      tok: <Id.VTest_ColonHyphen ':-'>
                      arg_word: {($ Id.VSub_DollarName '$title')}
                    )
                )
              }
            )
            (C {<sed>} {<-r>} {<-i>} 
              {(DQ <'s/Id.'> (${ Id.VSub_Name kind) <'_/Id.'> (${ Id.VSub_Name replace) <'_/g'>)} {<Id.Lit_Star '*'> <'/'> <Id.Lit_Star '*'> <.py>}
            )
            (C {<sed>} {<-r>} {<-i>} 
              {
                (DQ <'s/TokenKind.'> (${ Id.VSub_Name kind) <'/TokenKind.'> (${ Id.VSub_Name replace) 
                  <'/g'>
                )
              } {<Id.Lit_Star '*'> <'/'> <Id.Lit_Star '*'> <.py>}
            )
          ]
        )
    )
    (command.ShFunction
      name: replace
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'file='> ($ Id.VSub_Number '$1')})
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: 
                (condition.Shell
                  commands: [
                    (command.Sentence
                      child: (C {<read>} {<pat>} {<replace>})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              body: 
                (command.DoGroup
                  children: [
                    (C {<sed>} {<-r>} {<-i>} 
                      {(DQ <'s/'> (${ Id.VSub_Name pat) <'/'> (${ Id.VSub_Name replace) <'/g'>)} {<Id.Lit_Star '*'> <'/'> <Id.Lit_Star '*'> <.py>}
                    )
                  ]
                )
              redirects: [
                (redir
                  op: <Id.Redir_Less '<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: {($ Id.VSub_DollarName '$file')}
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: replace2
      body: 
        (BraceGroup
          children: [
            (C {<sed>} {<-r>} {<-i>} {(DQ <'s/^from core import runtime/from osh.meta import runtime/g'>)} 
              {<Id.Lit_Star '*'> <'/'> <Id.Lit_Star '*'> <.py>}
            )
          ]
        )
    )
    (command.ShFunction
      name: trailing-ws
      body: 
        (BraceGroup
          children: [(C {<sed>} {<-r>} {<-i>} {(SQ <'s/[ ]+$//g'>)} {(DQ ($ Id.VSub_At '$@'))})]
        )
    )
    (C {(DQ ($ Id.VSub_At '$@'))})
  ]
)