(command.CommandList children: [ (command.Sentence child: (command.ShFunction name: get_value_from_string body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ (${ Id.VSub_Number 1))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (C {<export>} {<Id.Lit_VarLike 'VAL='> (DQ (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<echo>} {(${ Id.VSub_Number 1)}) (C {<cut>} {<-d>} {(SQ <'='>)} {<-f>} {<2->}) ] negated: F ) ) ) } ) ] spids: [96 111] ) ] else_action: [ (C {<echo>} {(DQ <'Error: Did we forgot to supply a string to parse?'>)}) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] ) ] ) ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ShFunction name: get_value_from_cfg_with_spaces body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ (${ Id.VSub_Number 1))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (C {<export>} {<Id.Lit_VarLike 'VAL='> (DQ (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<grep>} {<Id.Lit_Other '^'> (${ Id.VSub_Number 1) <Id.Lit_Equals '='>} {(${ Id.VSub_Name CFGF)} ) (C {<head>} {<-n>} {<1>}) (C {<cut>} {<-d>} {(SQ <'='>)} {<-f>} {<2->}) ] negated: F ) ) ) } ) ] spids: [175 190] ) ] else_action: [ (C {<exit_err>} {(DQ <'Error: Did we forgot to supply a setting to grab?'>)}) ] ) ] ) ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ShFunction name: get_value_from_cfg body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ (${ Id.VSub_Number 1))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (C {<export>} {<Id.Lit_VarLike 'VAL='> (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<grep>} {(DQ <'^'> (${ Id.VSub_Number 1) <'='>)} {(${ Id.VSub_Name CFGF)} ) (C {<head>} {<-n>} {<1>}) (C {<cut>} {<-d>} {(SQ <'='>)} {<-f>} {<2->}) (C {<tr>} {<-d>} {(SQ <' '>)}) ] negated: F ) ) } ) ] spids: [264 279] ) ] else_action: [ (C {<exit_err>} {(DQ <'Error: Did we forgot to supply a setting to grab?'>)}) ] ) ] ) ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ShFunction name: if_check_value_exists body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ (${ Id.VSub_Number 1))} {<-a>} {<-n>} {(DQ (${ Id.VSub_Number 2))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VAL) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<grep>} {(DQ <'^'> (${ Id.VSub_Number 1))} {(${ Id.VSub_Name CFGF)} ) (C {<head>} {<-n>} {<1>}) (C {<cut>} {<-d>} {(SQ <'='>)} {<-f>} {<2->}) (C {<tr>} {<-d>} {(SQ <' '>)}) ] negated: F ) ) } spids: [398] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ (${ Id.VSub_Name VAL))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<0>} ) ] spids: [449 464] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VALID) op: assign_op.Equal rhs: {(DQ <1>)} spids: [481] ) ] ) (command.ForEach iter_name: i iter_words: [{(${ Id.VSub_Number 2)}] do_arg_iter: F body: (command.DoGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VAL) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<echo>} {(DQ ($ Id.VSub_DollarName '$VAL'))}) (C {<tr>} {<A-Z>} {<a-z>}) ] negated: F ) ) } spids: [501] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$VAL'))} {<Id.Lit_Equals '='>} {(DQ (${ Id.VSub_Name i))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VALID) op: assign_op.Equal rhs: {(DQ <0>)} spids: [542] ) ] ) ] spids: [519 538] ) ] ) ] ) ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$VALID'))} {<Id.Lit_Equals '='>} {(DQ <1>)} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (C {<exit_err>} { (DQ <'Error: '> (${ Id.VSub_Number 1) <' is set to unknown value '> ($ Id.VSub_DollarName '$VAL') ) } ) ] spids: [555 572] ) ] ) ] spids: [365 390] ) ] else_action: [ (C {<exit_err>} {(DQ <'Error: Did we forgot to supply a string to parse and setting to grab?'>)} ) ] ) ] ) ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ShFunction name: check_value body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ (${ Id.VSub_Number 1))} {<-a>} {<-n>} {(DQ (${ Id.VSub_Number 2))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VAL) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<grep>} {(DQ <'^'> (${ Id.VSub_Number 1))} {(${ Id.VSub_Name CFGF)} ) (C {<head>} {<-n>} {<1>}) (C {<cut>} {<-d>} {(SQ <'='>)} {<-f>} {<2->}) (C {<tr>} {<-d>} {(SQ <' '>)}) ] negated: F ) ) } spids: [651] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VALID) op: assign_op.Equal rhs: {(DQ <1>)} spids: [702] ) ] ) (command.ForEach iter_name: i iter_words: [{(${ Id.VSub_Number 2)}] do_arg_iter: F body: (command.DoGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$VAL'))} {<Id.Lit_Equals '='>} {(DQ (${ Id.VSub_Name i))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VALID) op: assign_op.Equal rhs: {(DQ <0>)} spids: [745] ) ] ) ] spids: [722 741] ) ] ) ] ) ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$VALID'))} {<Id.Lit_Equals '='>} {(DQ <1>)} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (C {<exit_err>} { (DQ <'Error: '> (${ Id.VSub_Number 1) <' is set to unknown value '> ($ Id.VSub_DollarName '$VAL') ) } ) ] spids: [758 775] ) ] ) ] spids: [619 644] ) ] else_action: [ (C {<exit_err>} {(DQ <'Error: Did we forgot to supply a string to parse and setting to grab?'>)} ) ] ) ] ) ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ShFunction name: file_sanity_check body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {<-n>} {(DQ ($ Id.VSub_DollarName '$CFGF'))} {<-a>} {<-n>} {(DQ ($ Id.VSub_Number '$1'))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (command.ForEach iter_name: i iter_words: [{($ Id.VSub_Number '$1')}] do_arg_iter: F body: (command.DoGroup children: [ (command.Simple words: [ {<grep>} {<-q>} {(DQ <'^'> (${ Id.VSub_Name i) <'='>)} {($ Id.VSub_DollarName '$CFGF')} ] redirects: [ (redir op: <Id.Redir_Great '2>'> loc: (redir_loc.Fd fd:2) arg: {<'/dev/null'>} ) ] do_fork: T ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {($ Id.VSub_QMark '$?')} {<-eq>} {<0>} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:LN) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<grep>} {(DQ <'^'> (${ Id.VSub_Name i) <'='>)} {(${ Id.VSub_Name CFGF)} ) (C {<head>} {<-n>} {<1>}) (C {<cut>} {<-d>} {(SQ <'='>)} {<-f>} {<2->}) (C {<tr>} {<-d>} {(SQ <' '>)}) ] negated: F ) ) } spids: [892] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ (${ Id.VSub_Name LN))} {<Id.Lit_RBracket ']'>} ) ] ) action: [ (C {<echo>} { (DQ <'Error: Config fails sanity test! '> (${ Id.VSub_Name i) <'= is empty'> ) } ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] spids: [944 959] ) ] ) ] spids: [876 889] ) ] else_action: [ (C {<echo>} { (DQ <'Error: Config fails sanity test! Missing '> (${ Id.VSub_Name i) <'='> ) } ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] ) ] ) ) ] spids: [822 843] ) ] else_action: [ (C {<echo>} {(DQ <'Error: Missing config file, and / or values to sanity check for!'>)} ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] ) ] ) ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ShFunction name: merge_config body: (BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:OLDCFG) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Number 1))} spids: [1041] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:NEWCFG) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Number 2))} spids: [1049] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FINALCFG) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Number 3))} spids: [1057] ) ] ) (C {<cp>} {(${ Id.VSub_Name OLDCFG)} {(${ Id.VSub_Name FINALCFG)}) (command.Pipeline children: [ (C {<cat>} {(${ Id.VSub_Name NEWCFG)}) (command.Simple words: [{<sed>} {(SQ <'/^$/d'>)}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {(${ Id.VSub_Name FINALCFG) <.tmp>} ) ] do_fork: T ) ] negated: F ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FOUNDMERGE) op: assign_op.Equal rhs: {(DQ <NO>)} spids: [1113] ) ] ) (command.WhileUntil keyword: <Id.KW_While while> cond: (condition.Shell commands:[(C {<read>} {<newline>})]) body: (command.DoGroup children: [ (command.Pipeline children: [ (C {<echo>} {(${ Id.VSub_Name newline)}) (command.Simple words: [{<grep>} {<-q>} {(DQ <'^#'>)}] redirects: [ (redir op: <Id.Redir_Great '2>'> loc: (redir_loc.Fd fd:2) arg: {<'/dev/null'>} ) ] do_fork: T ) ] negated: F ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_QMark '$?')} {<-ne>} {<0>} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VAL) op: assign_op.Equal rhs: { (DQ (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<echo>} {(${ Id.VSub_Name newline)}) (C {<cut>} {<-d>} {(SQ <'='>)} {<-f>} {<1>}) ] negated: F ) ) ) } spids: [1167] ) ] ) (command.Pipeline children: [ (C {<cat>} {(${ Id.VSub_Name OLDCFG)}) (command.Simple words: [{<grep>} {<-q>} {(${ Id.VSub_Name VAL)}] redirects: [ (redir op: <Id.Redir_Great '2>'> loc: (redir_loc.Fd fd:2) arg: {<'/dev/null'>} ) ] do_fork: T ) ] negated: F ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {($ Id.VSub_QMark '$?')} {<-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 '['>} {(DQ (${ Id.VSub_Name FOUNDMERGE))} {<Id.Lit_Equals '='>} {(DQ <NO>)} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.Simple words: [{<echo>} {(DQ )}] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: {(${ Id.VSub_Name FINALCFG)} ) ] do_fork: T ) (command.Simple words: [ {<echo>} { (DQ <'# Auto-merged values from newer '> (${ Id.VSub_Name NEWCFG) ) } ] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: {(${ Id.VSub_Name FINALCFG)} ) ] do_fork: T ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FOUNDMERGE) op: assign_op.Equal rhs: {(DQ <YES>)} spids: [1283] ) ] ) ] spids: [1232 1252] ) ] ) (command.Simple words: [{<echo>} {(DQ (${ Id.VSub_Name newline))}] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: {(${ Id.VSub_Name FINALCFG)} ) ] do_fork: T ) ] spids: [1215 1229] ) ] ) ] spids: [1150 1164] ) ] ) ] ) redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {(${ Id.VSub_Name FINALCFG) <.tmp>} ) ] ) (C {<rm>} {(${ Id.VSub_Name FINALCFG) <.tmp>}) ] ) ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ShFunction name: check_for_mount body: (BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:MNTS) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Number 1))} spids: [1345] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FINDMNT) op: assign_op.Equal rhs: {(DQ (${ Id.VSub_Number 2))} spids: [1353] ) ] ) (command.ForEach iter_name: CHECKMNT iter_words: [ { (command_sub left_token: <Id.Left_Backtick '`'> child: (command.Pipeline children: [ (C {<echo>} {(${ Id.VSub_Name MNTS)}) (C {<sed>} {(SQ <'s|,| |g'>)}) ] negated: F ) ) } ] do_arg_iter: F body: (command.DoGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {(DQ (${ Id.VSub_Name CHECKMNT))} {<Id.Lit_Equals '='>} {(DQ (${ Id.VSub_Name FINDMNT))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<0>} ) ] spids: [1394 1416] ) ] ) ] ) ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] ) ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ShFunction name: get_next_cfg_line body: (BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:CURFILE) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_Number '$1'))} spids: [1450] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:CURLINE) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_Number '$2'))} spids: [1456] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FOUND) op: assign_op.Equal rhs: {(DQ <1>)} spids: [1463] ) ] ) (command.WhileUntil keyword: <Id.KW_While while> cond: (condition.Shell commands:[(C {<read>} {<line>})]) body: (command.DoGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$FOUND'))} {<Id.Lit_Equals '='>} {(DQ <0>)} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (C {<export>} {<Id.Lit_VarLike 'VAL='> (DQ ($ Id.VSub_DollarName '$line'))} ) (command.ControlFlow token: <Id.ControlFlow_Return return> ) ] spids: [1481 1499] ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Sentence child: (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$line'))} {<Id.Lit_Equals '='>} {(DQ (${ Id.VSub_Name CURLINE))} {<Id.Lit_RBracket ']'>} ) terminator: <Id.Op_Semi _> ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FOUND) op: assign_op.Equal rhs: {(DQ <0>)} spids: [1539] ) ] ) ] spids: [1516 1536] ) ] ) ] ) redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {(${ Id.VSub_Name CURFILE)} ) ] ) (C {<export>} {<Id.Lit_VarLike 'VAL='> (DQ )}) ] ) ) terminator: <Id.Op_Semi _> ) ] )