(CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:currentVersion) op:Equal rhs:{(DQ (1.11.1))} spids:[7])] spids: [7] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:state) op:Equal rhs:{(DQ )} spids:[12])] spids: [12] ) (FuncDef name: checkOpenSSL body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(command)} {(-v)} {(openssl)})] negated:True) terminator: <Op_Amp '&'> ) (Sentence child: (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(/dev/null)} spids: [35] ) ] ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ('Error: to use this tool openssl must be installed'))}] redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[48])] ) (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] spids: [16777215 39] ) ] else_action: [(ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})] spids: [57 65] ) ] spids: [21] ) spids: [17 20] ) (FuncDef name: encrypt body: (BraceGroup children: [ (C {(echo)} {(DQ ('Encrypting ') ($ VSub_Number '$1') (...))}) (AndOr children: [ (C {(openssl)} {(enc)} {(-aes-256-cbc)} {(-salt)} {(-a)} {(-in)} {($ VSub_Number '$1')} {(-out)} {($ VSub_Number '$2')} ) (BraceGroup children: [ (Sentence child: (C {(echo)} {(DQ ('File not found'))}) terminator: <Op_Semi ';'> ) (Sentence child: (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] spids: [108] ) ] op_id: Op_DPipe ) (C {(echo)} {(DQ ('Successfully encrypted'))}) ] spids: [76] ) spids: [72 75] ) (FuncDef name: decrypt body: (BraceGroup children: [ (C {(echo)} {(DQ ('Decrypting ') ($ VSub_Number '$1') (...))}) (AndOr children: [ (C {(openssl)} {(enc)} {(-aes-256-cbc)} {(-d)} {(-a)} {(-in)} {($ VSub_Number '$1')} {(-out)} {($ VSub_Number '$2')} ) (BraceGroup children: [ (Sentence child: (C {(echo)} {(DQ ('File not found'))}) terminator: <Op_Semi ';'> ) (Sentence child: (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] spids: [173] ) ] op_id: Op_DPipe ) (C {(echo)} {(DQ ('Successfully decrypted'))}) ] spids: [141] ) spids: [137 140] ) (FuncDef name: update body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:repositoryName) op: Equal rhs: {(DQ (Bash-Snippets))} spids: [218] ) ] spids: [218] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:githubUserName) op: Equal rhs: {(DQ (alexanderepstein))} spids: [227] ) ] spids: [227] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nameOfInstallFile) op: Equal rhs: {(DQ (install.sh))} spids: [236] ) ] spids: [236] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:latestVersion) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(curl)} {(-s)} {(https) (Lit_Other ':') (//api.github.com/repos/) ($ VSub_Name '$githubUserName') (/) ($ VSub_Name '$repositoryName') (/tags) } ) (C {(grep)} {(-Eo)} {(SQ <'"name":.*?[^\\\\]",'>)}) (C {(head)} {(-1)}) (C {(grep)} {(-Eo)} {(DQ ('[0-9.]+'))}) ] negated: False ) ] ) left_token: <Left_CommandSub '$('> spids: [246 284] ) } spids: [245] ) ] spids: [245] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name '$currentVersion')} right: {(DQ )} ) right: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name '$repositoryName')} right: {(DQ )} ) right: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name '$githubUserName')} right: {(DQ )} ) right: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name '$nameOfInstallFile')} right: {(DQ )} ) ) ) ) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [ {(echo)} {(DQ ('Error: update utility has not been configured correctly.'))} ] redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[340])] ) (C {(exit)} {(1)}) ] spids: [16777215 331] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name '$latestVersion')} right: {(DQ )} ) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ('Error: no active internet connection'))}] redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[371])] ) (C {(exit)} {(1)}) ] spids: [349 362] ) ] else_action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {(DQ ($ VSub_Name '$latestVersion'))} right: {(DQ ($ VSub_Name '$currentVersion'))} ) ) terminator: <Op_Semi ';'> ) ] action: [ (C {(echo)} {(DQ ('Version ') ($ VSub_Name '$latestVersion') (' available'))}) (C {(echo)} {(-n)} { (DQ ('Do you wish to update ') ($ VSub_Name '$repositoryName') (' [Y/n]: ')) } ) (C {(read)} {(-r)} {(answer)}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name '$answer'))} right: {(DQ (Y))} ) right: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name '$answer'))} right: {(DQ (y))} ) ) ) terminator: <Op_Semi ';'> ) ] action: [ (AndOr children: [ (C {(cd)} {(TildeSubPart prefix:'')}) (BraceGroup children: [ (Sentence child: (C {(echo)} {(SQ <'Update Failed'>)}) terminator: <Op_Semi ';'> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ';'> ) ] spids: [468] ) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_d child: {(Lit_Tilde '~') (/) ($ VSub_Name '$repositoryName') } ) ) terminator: <Op_Semi ';'> ) ] action: [ (Sentence child: (AndOr children: [ (C {(rm)} {(-r)} {(-f)} {($ VSub_Name '$repositoryName')}) (BraceGroup children: [ (Sentence child: (C {(echo)} { (DQ ( 'Permissions Error: try running the update as sudo' ) ) } ) terminator: <Op_Semi ';'> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ';'> ) ] spids: [512] ) ] op_id: Op_DPipe ) terminator: <Op_Semi ';'> ) ] spids: [16777215 500] ) ] spids: [16777215 530] ) (AndOr children: [ (C {(git)} {(clone)} { (DQ ('https://github.com/') ($ VSub_Name '$githubUserName') (/) ($ VSub_Name '$repositoryName') ) } ) (BraceGroup children: [ (Sentence child: (C {(echo)} {(DQ ("Couldn't download latest version"))}) terminator: <Op_Semi ';'> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ';'> ) ] spids: [546] ) ] op_id: Op_DPipe ) (AndOr children: [ (C {(cd)} {($ VSub_Name '$repositoryName')}) (BraceGroup children: [ (Sentence child: (C {(echo)} {(SQ <'Update Failed'>)}) terminator: <Op_Semi ';'> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ';'> ) ] spids: [570] ) ] op_id: Op_DPipe ) (AndOr children: [ (SimpleCommand words: [ {(git)} {(checkout)} {(DQ (v) ($ VSub_Name '$latestVersion'))} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [597] ) ] ) (AndOr children: [ (SimpleCommand words: [ {(git)} {(checkout)} {(DQ ($ VSub_Name '$latestVersion'))} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [611] ) ] ) (C {(echo)} { (DQ ( "Couldn't git checkout to stable release, updating to latest commit." ) ) } ) ] op_id: Op_DPipe ) ] op_id: Op_DPipe ) (C {(chmod)} {(a) (Lit_Other '+') (x)} {(install.sh)}) (AndOr children: [ (C {(./) ($ VSub_Name '$nameOfInstallFile')} {(DQ (update))}) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) (C {(cd)} {(..)}) (AndOr children: [ (C {(rm)} {(-r)} {(-f)} {($ VSub_Name '$repositoryName')}) (BraceGroup children: [ (Sentence child: (C {(echo)} { (DQ ( 'Permissions Error: update succesfull but cannot delete temp files located at ~/' ) ($ VSub_Name '$repositoryName') (' delete this directory with sudo') ) } ) terminator: <Op_Semi ';'> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ';'> ) ] spids: [665] ) ] op_id: Op_DPipe ) ] spids: [16777215 459] ) ] else_action: [(C {(exit)} {(1)})] spids: [684 692] ) ] spids: [16777215 400] ) ] else_action: [ (C {(echo)} {(DQ ($ VSub_Name '$repositoryName') (' is already the latest version'))} ) ] spids: [695 706] ) ] spids: [380 709] ) ] spids: [203] ) spids: [199 202] ) (FuncDef name: usage body: (BraceGroup children: [ (C {(echo)} {(DQ (Crypt))}) (C {(echo)} { (DQ ( 'Description: A wrapper around openssl that facilitates encrypting and decrypting files.' ) ) } ) (C {(echo)} {(DQ ('Usage: crypt [flag] [inputFile] [outputFile]'))}) (C {(echo)} {(DQ (' -e Encrypt the inputFile and store it in the outputFile'))}) (C {(echo)} {(DQ (' -d Decrypt the inputFile and store it in the outputFile'))}) (C {(echo)} {(DQ (' -u Update Bash-Snippet Tools'))}) (C {(echo)} {(DQ (' -h Show the help'))}) (C {(echo)} {(DQ (' -v Get the tool version'))}) (C {(echo)} {(DQ ('Examples:'))}) (C {(echo)} { (DQ ( ' crypt -e mySecretFile.txt myEncryptedFile.jpg (change filetype so default program is incorrect)' ) ) } ) (C {(echo)} { (DQ ( ' crypt -d myEncryptedFile.jpg thisIsNowDecrypted.txt (change filetype back so now default program is correct)' ) ) } ) ] spids: [720] ) spids: [716 719] ) (AndOr children:[(C {(checkOpenSSL)}) (C {(exit)} {(1)})] op_id:Op_DPipe) (While cond: [(Sentence child:(C {(getopts)} {(DQ ('huve:d:'))} {(opt)}) terminator:<Op_Semi ';'>)] body: (DoGroup children: [ (Case to_match: {($ VSub_Name '$opt')} arms: [ (case_arm pat_list: [{(e)}] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name '$state')} right: {(DQ (decrypt))} ) ) terminator: <Op_Semi ';'> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:state) op: Equal rhs: {(DQ (encrypt))} spids: [859] ) ] spids: [859] ) ] spids: [16777215 856] ) ] else_action: [ (SimpleCommand words: [{(echo)} {(DQ ('Error: the -d and -e options are mutally exclusive'))}] redirects: [ (Redir op_id: Redir_GreatAnd fd: 16777215 arg_word: {(2)} spids: [874] ) ] ) (C {(exit)} {(1)}) ] spids: [865 883] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_ne left: {($ VSub_Pound '$#')} right: {(3)} ) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ( 'Option -e needs and only accepts two arguments [file to encrypt] [output file]' ) ) } ] redirects: [ (Redir op_id: Redir_GreatAnd fd: 16777215 arg_word: {(2)} spids: [908] ) ] ) (C {(exit)} {(1)}) ] spids: [16777215 899] ) ] spids: [16777215 917] ) ] spids: [835 836 921 16777215] ) (case_arm pat_list: [{(EscapedLiteralPart token:<Lit_EscapedChar '\\?'>)}] action: [ (SimpleCommand words: [{(echo)} {(DQ ('Invalid option: -') ($ VSub_Name '$OPTARG'))}] redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[935])] ) (C {(exit)} {(1)}) ] spids: [924 925 944 16777215] ) (case_arm pat_list: [{(d)}] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name '$state')} right: {(DQ (encrypt))} ) ) terminator: <Op_Semi ';'> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:state) op: Equal rhs: {(DQ (decrypt))} spids: [971] ) ] spids: [971] ) ] spids: [16777215 968] ) ] else_action: [ (SimpleCommand words: [{(echo)} {(DQ ('Error: the -e and -d options are mutally exclusive'))}] redirects: [ (Redir op_id: Redir_GreatAnd fd: 16777215 arg_word: {(2)} spids: [986] ) ] ) (C {(exit)} {(1)}) ] spids: [977 995] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_ne left: {($ VSub_Pound '$#')} right: {(3)} ) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ( 'Option -d needs and only accepts two arguments [file to decrypt] [output file]' ) ) } ] redirects: [ (Redir op_id: Redir_GreatAnd fd: 16777215 arg_word: {(2)} spids: [1020] ) ] ) (C {(exit)} {(1)}) ] spids: [16777215 1011] ) ] spids: [16777215 1029] ) ] spids: [947 948 1032 16777215] ) (case_arm pat_list: [{(u)}] action: [(C {(update)}) (C {(exit)} {(0)})] spids: [1035 1036 1047 16777215] ) (case_arm pat_list: [{(h)}] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [1050 1051 1062 16777215] ) (case_arm pat_list: [{(v)}] action: [ (C {(echo)} {(DQ ('Version ') ($ VSub_Name '$currentVersion'))}) (C {(exit)} {(0)}) ] spids: [1065 1066 1082 16777215] ) (case_arm pat_list: [{(Lit_Other ':')}] action: [ (SimpleCommand words: [ {(echo)} {(DQ ('Option -') ($ VSub_Name '$OPTARG') (' requires an argument.'))} ] redirects: [ (Redir op_id: Redir_GreatAnd fd: 16777215 arg_word: {(2)} spids: [1100] ) ] ) (C {(exit)} {(1)}) ] spids: [1085 1086 1109 16777215] ) ] spids: [828 832 1112] ) ] spids: [822 1114] ) ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_GlobDEqual left:{($ VSub_Pound '$#')} right:{(0)}) ) terminator: <Op_Semi ';'> ) ] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [16777215 1130] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number '$1')} right: {(DQ (update))} ) ) terminator: <Op_Semi ';'> ) ] action: [(C {(update)}) (C {(exit)} {(0)})] spids: [1140 1154] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number '$1')} right: {(DQ (help))} ) ) terminator: <Op_Semi ';'> ) ] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [1164 1178] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name '$state')} right: {(DQ (encrypt))} ) ) terminator: <Op_Semi ';'> ) ] action: [ (AndOr children: [ (C {(encrypt)} {($ VSub_Number '$2')} {($ VSub_Number '$3')}) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) (C {(exit)} {(0)}) ] spids: [1188 1202] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name '$state')} right: {(DQ (decrypt))} ) ) terminator: <Op_Semi ';'> ) ] action: [ (AndOr children: [ (C {(decrypt)} {($ VSub_Number '$2')} {($ VSub_Number '$3')}) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) (C {(exit)} {(0)}) ] spids: [1222 1236] ) ] spids: [16777215 1256] ) ] )