(command.CommandList
  children: [
    (C {<Id.KW_Set set>} {<-o>} {<nounset>})
    (C {<Id.KW_Set set>} {<-o>} {<pipefail>})
    (C {<Id.KW_Set set>} {<-o>} {<errexit>})
    (command.ShFunction
      name: change-kind
      body: 
        (command.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
                      op_id: 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: 
        (command.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 op_id:Id.VOp1_DComma arg_word:{})
                )
              }
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'title='> 
                (braced_var_sub
                  token: <Id.VSub_Name lower>
                  suffix_op: (suffix_op.Unary op_id:Id.VOp1_Caret arg_word:{})
                )
              }
            )
            (C {<local>} 
              {<Id.Lit_VarLike 'replace='> 
                (braced_var_sub
                  token: <Id.VSub_Number 2>
                  suffix_op: 
                    (suffix_op.Unary
                      op_id: 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: 
        (command.BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'file='> ($ Id.VSub_Number '$1')})
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: [
                (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.Redir
                  op: <Id.Redir_Less '<'>
                  fd: -1
                  arg_word: {($ Id.VSub_DollarName '$file')}
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: replace2
      body: 
        (command.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: 
        (command.BraceGroup
          children: [(C {<sed>} {<-r>} {<-i>} {(SQ <'s/[ ]+$//g'>)} {(DQ ($ Id.VSub_At '$@'))})]
        )
    )
    (C {(DQ ($ Id.VSub_At '$@'))})
  ]
)