#!/bin/bash if [[ $# != 2 ]] { echo >&2 "Usage $0 BASH_PROGRAM PREFIX> !2 "Usage $0 BASH_PROGRAM PREFIX" exit 3 } global SH_PROG := $1 global PREFIX := $2 typeset -i rc=0 global bash_loc := $[$SH_PROG -c 'echo ${SHELL}] global rc := $Status if (( rc != 0 )) { echo >&2 "Something went wrong in getting \$SHELL for $SH_PROG> !2 "Something went wrong in getting \$SHELL for $SH_PROG" exit $rc } if [[ -z $bash_loc ]] { echo >&2 "Something went wrong in setting bash location from \$SHELL for $SH_PROG> !2 "Something went wrong in setting bash location from \$SHELL for $SH_PROG" exit 3 } global bashdb_main := $[strings $SH_PROG | grep bashdb] global check_loc := $[dirname $[dirname $bashdb_main]] if [[ $PREFIX != $check_loc ]] { echo >&2 "bash says prefix should be $check_loc. You gave $PREFIX> !2 "bash says prefix should be $check_loc. You gave $PREFIX" exit 4 } exit 0 (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_GlobNEqual left:{($ VSub_Pound "$#")} right:{(2)}) ) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Usage ") ($ VSub_Number "$0") (" BASH_PROGRAM PREFIX"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[21])] ) (C {(exit)} {(3)}) ] spids: [-1 16] ) ] spids: [-1 35] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:SH_PROG) op:Equal rhs:{($ VSub_Number "$1")} spids:[37])] spids: [37] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:PREFIX) op:Equal rhs:{($ VSub_Number "$2")} spids:[40])] spids: [40] ) (C {(typeset)} {(-i)} {(Lit_VarLike "rc=") (0)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:bash_loc) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {($ VSub_Name "$SH_PROG")} {(-c)} {(SQ <"echo ${SHELL}">)})] ) left_token: spids: [51 59] ) } spids: [50] ) ] spids: [50] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:rc) op:Equal rhs:{($ VSub_QMark "$?")} spids:[61])] spids: [61] ) (If arms: [ (if_arm cond: [ (Sentence child: (DParen child: (ArithBinary op_id: Arith_NEqual left: (ArithVarRef name:rc) right: (ArithWord w:{(Lit_Digits 0)}) ) ) terminator: ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Something went wrong in getting ") (EscapedLiteralPart token:) ("SHELL for ") ($ VSub_Name "$SH_PROG") ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[84])] ) (C {(exit)} {($ VSub_Name "$rc")}) ] spids: [-1 79] ) ] spids: [-1 99] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr:(BoolUnary op_id:BoolUnary_z child:{($ VSub_Name "$bash_loc")})) terminator: ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Something went wrong in setting bash location from ") (EscapedLiteralPart token:) ("SHELL for ") ($ VSub_Name "$SH_PROG") ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[118])] ) (C {(exit)} {(3)}) ] spids: [-1 113] ) ] spids: [-1 133] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:bashdb_main) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [(C {(strings)} {($ VSub_Name "$SH_PROG")}) (C {(grep)} {(bashdb)})] negated: False ) ] ) left_token: spids: [136 146] ) } spids: [135] ) ] spids: [135] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:check_loc) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(dirname)} { (CommandSubPart command_list: (CommandList children: [(C {(dirname)} {($ VSub_Name "$bashdb_main")})] ) left_token: spids: [152 156] ) } ) ] ) left_token: spids: [149 157] ) } spids: [148] ) ] spids: [148] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$PREFIX")} right: {($ VSub_Name "$check_loc")} ) ) terminator: ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("bash says prefix should be ") ($ VSub_Name "$check_loc") (". You gave ") ($ VSub_Name "$PREFIX") ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[178])] ) (C {(exit)} {(4)}) ] spids: [-1 173] ) ] spids: [-1 193] ) (C {(exit)} {(0)}) ] )