(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LIB_VERSION) op: assign_op.Equal rhs: {(DQ <2.0.0>)} spids: [19] ) ] ) (C {<readonly>} {<KOALEPHANT_LIB_VERSION>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LIB_PATH) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_LIB_PATH> suffix_op: (suffix_op.Unary tok: <Id.VTest_ColonHyphen ':-'> arg_word: {<PREFIX> <Id.Lit_Slash '/'> <LIBRARY_PATH>} ) ) ) } spids: [32] ) ] ) (C {<readonly>} {<KOALEPHANT_LIB_PATH>}) (command.ShFunction name: k_tool_name body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-n>} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_TOOL_NAME> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:(word.Empty)) ) ) } {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [(C {<printf>} {(DQ <'%s'>)} {(DQ (${ Id.VSub_Name KOALEPHANT_TOOL_NAME))})] spids: [79 95] ) ] else_action: [(C {<k_fs_basename>} {(DQ (${ Id.VSub_Number 0))} {(DQ <.sh>)})] ) ] ) ) (command.ShFunction name: k_tool_version body: (BraceGroup children: [ (C {<printf>} {(DQ <'%s'>)} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_TOOL_VERSION> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:{<1.0.0>}) ) ) } ) ] ) ) (command.ShFunction name: k_tool_year body: (BraceGroup children: [ (C {<printf>} {(DQ <'%s'>)} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_TOOL_YEAR> suffix_op: (suffix_op.Unary tok: <Id.VTest_ColonHyphen ':-'> arg_word: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<date>} {<Id.Lit_Other '+'> <Id.Lit_Other '%'> <Y>}) ) } ) ) ) } ) ] ) ) (command.ShFunction name: k_tool_owner body: (BraceGroup children: [ (C {<printf>} {(DQ <'%s'>)} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_TOOL_OWNER> suffix_op: (suffix_op.Unary tok: <Id.VTest_ColonHyphen ':-'> arg_word: {<'Koalephant Co., Ltd'>} ) ) ) } ) ] ) ) (command.ShFunction name: k_tool_description body: (BraceGroup children: [ (C {<printf>} {(DQ <'%s'>)} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_TOOL_DESCRIPTION> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:(word.Empty)) ) ) } ) ] ) ) (command.ShFunction name: k_tool_options body: (BraceGroup children: [ (C {<printf>} {(DQ <'%s'>)} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_TOOL_OPTIONS> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:(word.Empty)) ) ) } ) ] ) ) (command.ShFunction name: k_tool_options_arguments body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-n>} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_tool_options>}) ) ) } {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (C {<printf>} {(DQ <' %s'>)} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_TOOL_OPTIONS_ARGUMENTS> suffix_op: (suffix_op.Unary tok: <Id.VTest_ColonHyphen ':-'> arg_word: {<'[options]'>} ) ) ) } ) ] spids: [393 408] ) ] ) ] ) ) (command.ShFunction name: k_tool_arguments body: (BraceGroup children: [ (C {<printf>} {(DQ <' %s'>)} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_TOOL_ARGUMENTS> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:(word.Empty)) ) ) } ) ] ) ) (command.ShFunction name: k_tool_usage body: (BraceGroup children: [ (C {<printf>} {(DQ <'Usage: %s%s%s'> <Id.Lit_BadBackslash '\\'> <n>)} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_name>})))} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_options_arguments>})))} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_arguments>})))} ) ] ) ) (command.ShFunction name: k_version body: (BraceGroup children: [ (C {<printf>} { (DQ <'%s version %s '> <Id.Lit_BadBackslash '\\'> <'nCopyright (c) %s, %s'> <Id.Lit_BadBackslash '\\'> <n> ) } {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_name>})))} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_version>})))} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_year>})))} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_owner>})))} ) ] ) ) (command.ShFunction name: k_usage body: (BraceGroup children: [ (C {<printf>} {(DQ <'%s'> <Id.Lit_BadBackslash '\\'> <n>)} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_usage>})))} ) (C {<printf>} {(DQ <'%s'> <Id.Lit_BadBackslash '\\'> <n> <Id.Lit_BadBackslash '\\'> <n>)} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_description>})))} ) (C {<printf>} {(DQ <'%s'> <Id.Lit_BadBackslash '\\'> <n>)} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<k_tool_options>})))} ) ] ) ) (command.ShFunction name: k_require_root body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<id>} {<-u>}) ) ) } {<-ne>} {<0>} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ (${ Id.VSub_Number 1))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [(C {<k_log_err>} {(DQ (${ Id.VSub_Number 1))})] spids: [715 730] ) ] ) (C {<k_log_err>} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_tool_name>}) ) <' must be run as root'> ) } ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] spids: [693 712] ) ] ) ] ) ) (command.ShFunction name: k_option_requires_arg body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<Id.Lit_LBracket '['>} {<-n>} { (DQ (braced_var_sub token: <Id.VSub_Number 2> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:(word.Empty)) ) ) } {<Id.Lit_RBracket ']'>} ) (command.Pipeline children: [ (C {<k_string_starts_with>} {(DQ <->)} {(DQ (${ Id.VSub_Number 2))}) ] negated: T ) ] ) terminator: <Id.Op_Semi _> ) ] ) action: [(C {<printf>} {(SQ <'%s'>)} {(DQ (${ Id.VSub_Number 2))})] spids: [805 837] ) ] else_action: [ (C {<k_log_err>} {(DQ <'Error, '> (${ Id.VSub_Number 1) <' requires an argument'>)}) (C {<k_usage>}) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] ) ] ) ) (command.ShFunction name: k_option_optional_arg body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'tool='> (DQ ($ Id.VSub_Number '$1'))}) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<Id.Lit_LBracket '['>} {<-n>} { (DQ (braced_var_sub token: <Id.VSub_Number 2> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:(word.Empty)) ) ) } {<Id.Lit_RBracket ']'>} ) (command.Pipeline children: [ (C {<k_string_starts_with>} {(DQ <->)} {(DQ (${ Id.VSub_Number 2))}) ] negated: T ) ] ) terminator: <Id.Op_Semi _> ) ] ) action: [(C {<printf>} {(SQ <'%s'>)} {(DQ (${ Id.VSub_Number 2))})] spids: [919 951] ) ] ) ] ) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LOG_LEVEL_EMERG) op: assign_op.Equal rhs: {<1>} spids: [975] ) ] ) (C {<readonly>} {<KOALEPHANT_LOG_LEVEL_EMERG>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LOG_LEVEL_ALERT) op: assign_op.Equal rhs: {<2>} spids: [986] ) ] ) (C {<readonly>} {<KOALEPHANT_LOG_LEVEL_ALERT>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LOG_LEVEL_CRIT) op: assign_op.Equal rhs: {<3>} spids: [997] ) ] ) (C {<readonly>} {<KOALEPHANT_LOG_LEVEL_CRIT>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LOG_LEVEL_ERR) op: assign_op.Equal rhs: {<4>} spids: [1008] ) ] ) (C {<readonly>} {<KOALEPHANT_LOG_LEVEL_ERR>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LOG_LEVEL_WARNING) op: assign_op.Equal rhs: {<5>} spids: [1019] ) ] ) (C {<readonly>} {<KOALEPHANT_LOG_LEVEL_WARNING>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LOG_LEVEL_NOTICE) op: assign_op.Equal rhs: {<6>} spids: [1030] ) ] ) (C {<readonly>} {<KOALEPHANT_LOG_LEVEL_NOTICE>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LOG_LEVEL_INFO) op: assign_op.Equal rhs: {<7>} spids: [1041] ) ] ) (C {<readonly>} {<KOALEPHANT_LOG_LEVEL_INFO>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LOG_LEVEL_DEBUG) op: assign_op.Equal rhs: {<8>} spids: [1052] ) ] ) (C {<readonly>} {<KOALEPHANT_LOG_LEVEL_DEBUG>}) (command.ShFunction name: k_log_level_valid body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_Number '$1'))} {<-ge>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_EMERG)} {<Id.Lit_RBracket ']'>} ) (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_Number '$1'))} {<-le>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_DEBUG)} {<Id.Lit_RBracket ']'>} ) ] ) ] ) ) (command.ShFunction name: k_log_level body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_Pound '$#')} {<-eq>} {<1>} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (command.Pipeline children: [ (C {<k_log_level_valid>} {(DQ ($ Id.VSub_Number '$1'))}) ] negated: T ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Simple words: [{<printf>} {(DQ <'%s'>)} {(DQ <'Invalid log level specified'>)}] redirects: [ (redir op: <Id.Redir_GreatAnd '>&'> loc: (redir_loc.Fd fd:1) arg: {<2>} ) ] do_fork: T ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] spids: [1159 1170] ) ] else_action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:KOALEPHANT_LOG_LEVEL_ACTIVE) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_Number '$1'))} spids: [1195] ) ] ) ] ) ] spids: [1143 1156] ) ] ) (C {<printf>} {(SQ <'%d'>)} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_LOG_LEVEL_ACTIVE> suffix_op: (suffix_op.Unary tok: <Id.VTest_ColonHyphen ':-'> arg_word: {($ Id.VSub_DollarName '$KOALEPHANT_LOG_LEVEL_ERR')} ) ) ) } ) ] ) ) (command.ShFunction name: k_log_level_name body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (command.Pipeline children: [(C {<k_log_level_valid>} {(DQ ($ Id.VSub_Number '$1'))})] negated: T ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Simple words: [{<printf>} {(DQ <'%s'>)} {(DQ <'Invalid log level specified'>)}] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] spids: [1235 1246] ) ] ) (command.Case to_match: {(DQ (${ Id.VSub_Number 1))} arms: [ (case_arm pat_list: [{(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_EMERG)}] action: [(C {<printf>} {(DQ <'%s'>)} {(DQ <emerg>)})] spids: [1282 1285 1299 -1] ) (case_arm pat_list: [{(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_ALERT)}] action: [(C {<printf>} {(DQ <'%s'>)} {(DQ <alert>)})] spids: [1303 1306 1320 -1] ) (case_arm pat_list: [{(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_CRIT)}] action: [(C {<printf>} {(DQ <'%s'>)} {(DQ <crit>)})] spids: [1324 1327 1341 -1] ) (case_arm pat_list: [{(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_ERR)}] action: [(C {<printf>} {(DQ <'%s'>)} {(DQ <err>)})] spids: [1345 1348 1362 -1] ) (case_arm pat_list: [{(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_WARNING)}] action: [(C {<printf>} {(DQ <'%s'>)} {(DQ <warning>)})] spids: [1366 1369 1383 -1] ) (case_arm pat_list: [{(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_NOTICE)}] action: [(C {<printf>} {(DQ <'%s'>)} {(DQ <notice>)})] spids: [1387 1390 1404 -1] ) (case_arm pat_list: [{(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_INFO)}] action: [(C {<printf>} {(DQ <'%s'>)} {(DQ <info>)})] spids: [1408 1411 1425 -1] ) (case_arm pat_list: [{(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_DEBUG)}] action: [(C {<printf>} {(DQ <'%s'>)} {(DQ <debug>)})] spids: [1429 1432 1446 -1] ) ] ) ] ) ) (command.ShFunction name: k_log_syslog body: (BraceGroup children: [ (C {<k_bool_test>} { (DQ (braced_var_sub token: <Id.VSub_Name KOALEPHANT_LOG_SYSLOG> suffix_op: (suffix_op.Unary tok:<Id.VTest_ColonHyphen ':-'> arg_word:(word.Empty)) ) ) } ) ] ) ) (command.ShFunction name: k_log_message body: (BraceGroup children: [ (C {<local>} {<Id.Lit_VarLike 'level='> (DQ ($ Id.VSub_Number '$1'))}) (C {<shift>}) (C {<local>} {<Id.Lit_VarLike 'message='> (DQ ($ Id.VSub_Star '$*'))}) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<k_log_level_valid>} {(DQ ($ Id.VSub_DollarName '$level'))}) (C {<Id.Lit_LBracket '['>} { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_log_level>}) ) } {<-ge>} {(DQ (${ Id.VSub_Name level))} {<Id.Lit_RBracket ']'>} ) ] ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Simple words: [ {<printf>} {(DQ <'%s'> <Id.Lit_BadBackslash '\\'> <n>)} {(DQ ($ Id.VSub_At '$@'))} ] redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})] do_fork: T ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<k_log_syslog>}) terminator: <Id.Op_Semi _> ) ] ) action: [ (C {<'/usr/bin/logger'>} {<--tag>} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_tool_name>}) ) ) } {<--id>} {($ Id.VSub_Dollar '$$')} {<--priority>} { (DQ <user.> (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<k_log_level_name>} {(DQ (${ Id.VSub_Name level))}) ) ) } {<-->} {(DQ ($ Id.VSub_At '$@'))} ) ] spids: [1579 1584] ) ] ) ] spids: [1533 1560] ) ] ) ] ) ) (command.ShFunction name: k_log_emerg body: (BraceGroup children: [ (C {<k_log_message>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_EMERG)} {(DQ ($ Id.VSub_At '$@'))} ) ] ) ) (command.ShFunction name: k_log_alert body: (BraceGroup children: [ (C {<k_log_message>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_ALERT)} {(DQ ($ Id.VSub_At '$@'))} ) ] ) ) (command.ShFunction name: k_log_crit body: (BraceGroup children: [ (C {<k_log_message>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_CRIT)} {(DQ ($ Id.VSub_At '$@'))}) ] ) ) (command.ShFunction name: k_log_err body: (BraceGroup children: [ (C {<k_log_message>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_ERR)} {(DQ ($ Id.VSub_At '$@'))}) ] ) ) (command.ShFunction name: k_log_warning body: (BraceGroup children: [ (C {<k_log_message>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_WARNING)} {(DQ ($ Id.VSub_At '$@'))} ) ] ) ) (command.ShFunction name: k_log_notice body: (BraceGroup children: [ (C {<k_log_message>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_NOTICE)} {(DQ ($ Id.VSub_At '$@'))} ) ] ) ) (command.ShFunction name: k_log_info body: (BraceGroup children: [ (C {<k_log_message>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_INFO)} {(DQ ($ Id.VSub_At '$@'))}) ] ) ) (command.ShFunction name: k_log_debug body: (BraceGroup children: [ (C {<k_log_message>} {(${ Id.VSub_Name KOALEPHANT_LOG_LEVEL_DEBUG)} {(DQ ($ Id.VSub_At '$@'))} ) ] ) ) ] )