(command.CommandList children: [ (command.ShFunction name: k_fs_resolve body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'path='> (DQ (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary op_id:Id.VOp1_Percent arg_word:{<Id.Lit_Slash '/'>}) ) ) } ) (C {<local>} {<Id.Lit_VarLike 'dir='> (DQ )}) (C {<local>} {<Id.Lit_VarLike 'base='> (DQ )}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-d>} {(DQ (${ Id.VSub_Name path))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dir) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Name path))} spids: [88] ) ] ) ] spids: [70 85] ) ] else_action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dir) op: assign_op.Equal rhs: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_fs_dirname>} {(DQ (${ Id.VSub_Name path))}) ) ) } spids: [99] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:base) op: assign_op.Equal rhs: { (DQ <'/'> (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_fs_basename>} {(DQ (${ Id.VSub_Name path))}) ) ) } spids: [113] ) ] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ (${ Id.VSub_Name dir))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dir) op: assign_op.Equal rhs: {(DQ <.>)} spids: [150] ) ] ) ] spids: [132 147] ) ] ) (C {<printf>} {(DQ <'%s%s'>)} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (command.AndOr ops: [Id.Op_DAmp] children: [(C {<cd>} {(DQ (${ Id.VSub_Name dir))}) (C {<pwd>} {<-P>})] ) ) ) } {(DQ (${ Id.VSub_Name base))} ) ] ) ) (command.ShFunction name: k_fs_basename body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'path='> (DQ (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary op_id:Id.VOp1_Percent arg_word:{<Id.Lit_Slash '/'>}) ) ) } ) (C {<local>} {<Id.Lit_VarLike 'extension='> (DQ (braced_var_sub token: <Id.VSub_Number 2> suffix_op: (suffix_op.Unary op_id:Id.VTest_ColonHyphen arg_word:(word.Empty)) ) ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:path) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: <Id.VSub_Name path> suffix_op: (suffix_op.Unary op_id: Id.VOp1_DPound arg_word: {<'*'> <Id.Lit_Slash '/'>} ) ) ) } spids: [248] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ (${ Id.VSub_Name extension))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:path) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: <Id.VSub_Name path> suffix_op: (suffix_op.Unary op_id: Id.VOp1_Percent arg_word: {($ Id.VSub_DollarName '$extension')} ) ) ) } spids: [278] ) ] ) ] spids: [260 275] ) ] ) (C {<printf>} {(DQ <'%s'>)} { (DQ (braced_var_sub token: <Id.VSub_Name path> suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonHyphen arg_word: {<Id.Lit_Slash '/'>} ) ) ) } ) ] ) ) (command.ShFunction name: k_fs_dirname body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'path='> (DQ (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary op_id:Id.VOp1_Percent arg_word:{<Id.Lit_Slash '/'>}) ) ) } ) (C {<local>} {<Id.Lit_VarLike 'dirPath='> (DQ (braced_var_sub token: <Id.VSub_Name path> suffix_op: (suffix_op.Unary op_id: Id.VOp1_Percent arg_word: {<Id.Lit_Slash '/'> <'*'>} ) ) ) } ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ (${ Id.VSub_Name path))} {<Id.Lit_RBracket ']'>} ) (C {<Id.Lit_LBracket '['>} {(DQ (${ Id.VSub_Name path))} {<Id.Lit_Equals '='>} {(DQ (${ Id.VSub_Name dirPath))} {<Id.Lit_RBracket ']'>} ) ] ) terminator: <Id.Op_Semi _> ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dirPath) op: assign_op.Equal rhs: {(DQ <.>)} spids: [401] ) ] ) ] spids: [363 398] ) ] ) (C {<printf>} {(DQ <'%s'>)} { (DQ (braced_var_sub token: <Id.VSub_Name dirPath> suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonHyphen arg_word: {<Id.Lit_Slash '/'>} ) ) ) } ) ] ) ) (command.ShFunction name: k_fs_temp_dir body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'tmpDir='> (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<mktemp>} {<-d>}))) } ) (C {<k_log_debug>} {(DQ <'Created temporary directory: \''> (${ Id.VSub_Name tmpDir) <'\''>)} ) (command.Simple words: [{<printf>} {(DQ <'%s'> <Id.Lit_Other '\\'> <n>)} {(DQ (${ Id.VSub_Name tmpDir))}] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_fs_predictable_file>} {<k-fs-temp-files>}) ) ) } ) ] do_fork: T ) (C {<printf>} {(DQ <'%s'>)} {(DQ (${ Id.VSub_Name tmpDir))}) ] ) ) (command.ShFunction name: k_fs_temp_file body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'tmpFile='> (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<mktemp>}))) } ) (C {<k_log_debug>} {(DQ <'Created temporary file: \''> (${ Id.VSub_Name tmpFile) <'\''>)}) (command.Simple words: [{<printf>} {(DQ <'%s'> <Id.Lit_Other '\\'> <n>)} {(DQ (${ Id.VSub_Name tmpFile))}] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_fs_predictable_file>} {<k-fs-temp-files>}) ) ) } ) ] do_fork: T ) (C {<printf>} {(DQ <'%s'>)} {(DQ (${ Id.VSub_Name tmpFile))}) ] ) ) (command.ShFunction name: k_fs_predictable_dir body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'tmpDir='> (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_fs_dirname>} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<mktemp>} {<-u>}) ) ) } ) ) <'/'> (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonHyphen arg_word: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_tool_name>}) ) } ) ) <.> ($ Id.VSub_Dollar '$$') ) } ) (C {<mkdir>} {<-p>} {(DQ (${ Id.VSub_Name tmpDir))}) (C {<k_log_debug>} {(DQ <'Created predictable temporary directory: \''> (${ Id.VSub_Name tmpDir) <'\''>)} ) (command.Simple words: [{<printf>} {(DQ <'%s'> <Id.Lit_Other '\\'> <n>)} {(DQ (${ Id.VSub_Name tmpDir))}] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_fs_predictable_file>} {<k-fs-temp-files>}) ) ) } ) ] do_fork: T ) (C {<printf>} {(DQ <'%s'>)} {(DQ (${ Id.VSub_Name tmpDir))}) ] ) ) (command.ShFunction name: k_fs_predictable_file body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'name='> (DQ (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonHyphen arg_word: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_tool_name>}) ) } ) ) ) } ) (C {<local>} {<Id.Lit_VarLike 'tmpFile='> (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_fs_dirname>} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<mktemp>} {<-u>}) ) ) } ) ) <'/'> (${ Id.VSub_Name name) <.> ($ Id.VSub_Dollar '$$') ) } ) (C {<k_log_debug>} {(DQ <'Created predictable temporary file: \''> (${ Id.VSub_Name tmpFile) <'\''>)} ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {(DQ (${ Id.VSub_Name name))} {<Id.Lit_Equals '='>} {(DQ <k-fs-temp-files>)} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<printf>} {(DQ <'%s'> <Id.Lit_Other '\\'> <n>)} {(DQ (${ Id.VSub_Name tmpFile))} ] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_fs_predictable_file>} {<k-fs-temp-files>}) ) ) } ) ] do_fork: T ) ] spids: [803 824] ) ] ) (C {<printf>} {(DQ <'%s'>)} {(DQ (${ Id.VSub_Name tmpFile))}) ] ) ) (command.ShFunction name: k_fs_temp_cleanup body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'tempFilesFile='> (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_fs_predictable_file>} {<k-fs-temp-files>}) ) ) } ) (C {<k_log_info>} {(DQ <'Cleaning up temp files'>)}) (command.WhileUntil keyword: <Id.KW_While while> cond: [ (command.Sentence child: (command.Simple words: [{<read>} {<-r>} {<file>}] more_env: [(env_pair name:IFS val:(word.Empty) spids:[902])] do_fork: T ) terminator: <Id.Op_Semi _> ) ] body: (command.DoGroup children: [ (C {<k_log_debug>} {(DQ <'Removing \''> (${ Id.VSub_Name file) <'\''>)}) (C {<rm>} {<-rf>} {(DQ (${ Id.VSub_Name file))}) ] ) redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {(DQ (${ Id.VSub_Name tempFilesFile))} ) ] ) (C {<k_log_debug>} {(DQ <'Removing \''> (${ Id.VSub_Name tempFilesFile) <'\''>)}) (C {<rm>} {<-f>} {(DQ (${ Id.VSub_Name tempFilesFile))}) ] ) ) ] )