(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:currentVersion) op: assign_op.Equal rhs: {(DQ <1.11.1>)} spids: [7] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:state) op: assign_op.Equal rhs: {(DQ )} spids: [12] ) ] ) (command.ShFunction name: checkOpenSSL body: (command.BraceGroup children: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (command.Simple words: [{<command>} {<-v>} {<openssl>}] redirects: [ (redir.Redir op: <Id.Redir_AndGreat '&>'> fd: -1 arg_word: {</dev/null>} ) ] ) ] negated: T ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [{<echo>} {(DQ <'Error: to use this tool openssl must be installed'>)}] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '>&'> fd:-1 arg_word:{<2>})] ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] spids: [24 38] ) ] else_action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})] ) ] ) ) (command.ShFunction name: encrypt body: (command.BraceGroup children: [ (C {<echo>} {(DQ <'Encrypting '> ($ Id.VSub_Number '$1') <...>)}) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<openssl>} {<enc>} {<-aes-256-cbc>} {<-salt>} {<-a>} {<-in>} {($ Id.VSub_Number '$1')} {<-out>} {($ Id.VSub_Number '$2')} ) (command.BraceGroup children: [ (command.Sentence child: (C {<echo>} {(DQ <'File not found'>)}) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>}) terminator: <Id.Op_Semi _> ) ] ) ] ) (C {<echo>} {(DQ <'Successfully encrypted'>)}) ] ) ) (command.ShFunction name: decrypt body: (command.BraceGroup children: [ (C {<echo>} {(DQ <'Decrypting '> ($ Id.VSub_Number '$1') <...>)}) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<openssl>} {<enc>} {<-aes-256-cbc>} {<-d>} {<-a>} {<-in>} {($ Id.VSub_Number '$1')} {<-out>} {($ Id.VSub_Number '$2')} ) (command.BraceGroup children: [ (command.Sentence child: (C {<echo>} {(DQ <'File not found'>)}) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>}) terminator: <Id.Op_Semi _> ) ] ) ] ) (C {<echo>} {(DQ <'Successfully decrypted'>)}) ] ) ) (command.ShFunction name: update body: (command.BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:repositoryName) op: assign_op.Equal rhs: {(DQ <Bash-Snippets>)} spids: [217] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:githubUserName) op: assign_op.Equal rhs: {(DQ <alexanderepstein>)} spids: [226] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:nameOfInstallFile) op: assign_op.Equal rhs: {(DQ <install.sh>)} spids: [235] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:latestVersion) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> command_list: (command.CommandList children: [ (command.Pipeline children: [ (C {<curl>} {<-s>} {<https> <Id.Lit_Other ':'> <//api.github.com/repos/> ($ Id.VSub_DollarName '$githubUserName') </> ($ Id.VSub_DollarName '$repositoryName') </tags> } ) (C {<grep>} {<-Eo>} {(SQ <'"name":.*?[^\\\\]",'>)}) (C {<head>} {<-1>}) (C {<grep>} {<-Eo>} {(DQ <'[0-9.]+'>)}) ] negated: F ) ] ) ) } spids: [244] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.LogicalOr left: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_DollarName '$currentVersion')} right: {(DQ )} ) right: (bool_expr.LogicalOr left: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_DollarName '$repositoryName')} right: {(DQ )} ) right: (bool_expr.LogicalOr left: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_DollarName '$githubUserName')} right: {(DQ )} ) right: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_DollarName '$nameOfInstallFile')} right: {(DQ )} ) ) ) ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<echo>} {(DQ <'Error: update utility has not been configured correctly.'>)} ] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '>&'> fd:-1 arg_word:{<2>})] ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] spids: [290 330] ) (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_DollarName '$latestVersion')} right: {(DQ )} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [{<echo>} {(DQ <'Error: no active internet connection'>)}] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '>&'> fd:-1 arg_word:{<2>})] ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] spids: [348 361] ) ] else_action: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobNEqual left: {(DQ ($ Id.VSub_DollarName '$latestVersion'))} right: {(DQ ($ Id.VSub_DollarName '$currentVersion'))} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (C {<echo>} {(DQ <'Version '> ($ Id.VSub_DollarName '$latestVersion') <' available'>)} ) (C {<echo>} {<-n>} { (DQ <'Do you wish to update '> ($ Id.VSub_DollarName '$repositoryName') <' [Y/n]: '> ) } ) (C {<read>} {<-r>} {<answer>}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.LogicalOr left: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {(DQ ($ Id.VSub_DollarName '$answer'))} right: {(DQ <Y>)} ) right: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {(DQ ($ Id.VSub_DollarName '$answer'))} right: {(DQ <y>)} ) ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<cd>} {(word_part.TildeSub token:<Id.Lit_TildeLike '~'>)}) (command.BraceGroup children: [ (command.Sentence child: (C {<echo>} {(SQ <'Update Failed'>)}) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) terminator: <Id.Op_Semi _> ) ] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: Id.BoolUnary_d child: {<Id.Lit_TildeLike '~'> </> ($ Id.VSub_DollarName '$repositoryName') } ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Sentence child: (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<rm>} {<-r>} {<-f>} {($ Id.VSub_DollarName '$repositoryName')} ) (command.BraceGroup children: [ (command.Sentence child: (C {<echo>} { (DQ < 'Permissions Error: try running the update as sudo' > ) } ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) terminator: <Id.Op_Semi _> ) ] ) ] ) terminator: <Id.Op_Semi _> ) ] spids: [486 499] ) ] ) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<git>} {<clone>} { (DQ <'https://github.com/'> ($ Id.VSub_DollarName '$githubUserName') </> ($ Id.VSub_DollarName '$repositoryName') ) } ) (command.BraceGroup children: [ (command.Sentence child: (C {<echo>} {(DQ <"Couldn't download latest version">)}) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) terminator: <Id.Op_Semi _> ) ] ) ] ) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<cd>} {($ Id.VSub_DollarName '$repositoryName')}) (command.BraceGroup children: [ (command.Sentence child: (C {<echo>} {(SQ <'Update Failed'>)}) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) terminator: <Id.Op_Semi _> ) ] ) ] ) (command.AndOr ops: [Id.Op_DPipe Id.Op_DPipe] children: [ (command.Simple words: [ {<git>} {<checkout>} {(DQ <v> ($ Id.VSub_DollarName '$latestVersion'))} ] redirects: [ (redir.Redir op: <Id.Redir_Great '2>'> fd: 2 arg_word: {</dev/null>} ) ] ) (command.Simple words: [ {<git>} {<checkout>} {(DQ ($ Id.VSub_DollarName '$latestVersion'))} ] redirects: [ (redir.Redir op: <Id.Redir_Great '2>'> fd: 2 arg_word: {</dev/null>} ) ] ) (C {<echo>} { (DQ < "Couldn't git checkout to stable release, updating to latest commit." > ) } ) ] ) (C {<chmod>} {<a> <Id.Lit_Other '+'> <x>} {<install.sh>}) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<./> ($ Id.VSub_DollarName '$nameOfInstallFile')} {(DQ <update>)} ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] ) (C {<cd>} {<..>}) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<rm>} {<-r>} {<-f>} {($ Id.VSub_DollarName '$repositoryName')}) (command.BraceGroup children: [ (command.Sentence child: (C {<echo>} { (DQ < 'Permissions Error: update succesfull but cannot delete temp files located at ~/' > ($ Id.VSub_DollarName '$repositoryName') <' delete this directory with sudo'> ) } ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) terminator: <Id.Op_Semi _> ) ] ) ] ) ] spids: [429 458] ) ] else_action: [ (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] ) ] spids: [382 399] ) ] else_action: [ (C {<echo>} { (DQ ($ Id.VSub_DollarName '$repositoryName') <' is already the latest version'> ) } ) ] ) ] ) ] ) ) (command.ShFunction name: usage body: (command.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)' > ) } ) ] ) ) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<checkOpenSSL>}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] ) (command.WhileUntil keyword: <Id.KW_While while> cond: [ (command.Sentence child: (C {<getopts>} {(DQ <'huve:d:'>)} {<opt>}) terminator: <Id.Op_Semi _> ) ] body: (command.DoGroup children: [ (command.Case to_match: {($ Id.VSub_DollarName '$opt')} arms: [ (case_arm pat_list: [{<e>}] action: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobNEqual left: {($ Id.VSub_DollarName '$state')} right: {(DQ <decrypt>)} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:state) op: assign_op.Equal rhs: {(DQ <encrypt>)} spids: [858] ) ] ) ] spids: [841 855] ) ] else_action: [ (command.Simple words: [{<echo>} {(DQ <'Error: the -d and -e options are mutally exclusive'>)}] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '>&'> fd:-1 arg_word:{<2>})] ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_Pound '$#')} right: {<3>} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<echo>} { (DQ < 'Option -e needs and only accepts two arguments [file to encrypt] [output file]' > ) } ] redirects: [ (redir.Redir op: <Id.Redir_GreatAnd '>&'> fd: -1 arg_word: {<2>} ) ] ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] spids: [885 898] ) ] ) ] spids: [834 835 920 -1] ) (case_arm pat_list: [{(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\?'>)}] action: [ (command.Simple words: [{<echo>} {(DQ <'Invalid option: -'> ($ Id.VSub_DollarName '$OPTARG'))}] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '>&'> fd:-1 arg_word:{<2>})] ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] spids: [923 924 943 -1] ) (case_arm pat_list: [{<d>}] action: [ (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobNEqual left: {($ Id.VSub_DollarName '$state')} right: {(DQ <encrypt>)} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:state) op: assign_op.Equal rhs: {(DQ <decrypt>)} spids: [970] ) ] ) ] spids: [953 967] ) ] else_action: [ (command.Simple words: [{<echo>} {(DQ <'Error: the -e and -d options are mutally exclusive'>)}] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '>&'> fd:-1 arg_word:{<2>})] ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_Pound '$#')} right: {<3>} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<echo>} { (DQ < 'Option -d needs and only accepts two arguments [file to decrypt] [output file]' > ) } ] redirects: [ (redir.Redir op: <Id.Redir_GreatAnd '>&'> fd: -1 arg_word: {<2>} ) ] ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] spids: [997 1010] ) ] ) ] spids: [946 947 1031 -1] ) (case_arm pat_list: [{<u>}] action: [ (C {<update>}) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<0>} ) ] spids: [1034 1035 1046 -1] ) (case_arm pat_list: [{<h>}] action: [ (C {<usage>}) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<0>} ) ] spids: [1049 1050 1061 -1] ) (case_arm pat_list: [{<v>}] action: [ (C {<echo>} {(DQ <'Version '> ($ Id.VSub_DollarName '$currentVersion'))}) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<0>} ) ] spids: [1064 1065 1081 -1] ) (case_arm pat_list: [{<Id.Lit_Other ':'>}] action: [ (command.Simple words: [ {<echo>} { (DQ <'Option -'> ($ Id.VSub_DollarName '$OPTARG') <' requires an argument.'>) } ] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '>&'> fd:-1 arg_word:{<2>})] ) (command.ControlFlow token: <Id.ControlFlow_Exit exit> arg_word: {<1>} ) ] spids: [1084 1085 1108 -1] ) ] ) ] ) ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_Pound '$#')} right: {<0>} ) ) terminator: <Id.Op_Semi _> ) ] action: [(C {<usage>}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<0>})] spids: [1116 1129] ) (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_Number '$1')} right: {(DQ <update>)} ) ) terminator: <Id.Op_Semi _> ) ] action: [(C {<update>}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<0>})] spids: [1139 1153] ) (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_Number '$1')} right: {(DQ <help>)} ) ) terminator: <Id.Op_Semi _> ) ] action: [(C {<usage>}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<0>})] spids: [1163 1177] ) (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_DollarName '$state')} right: {(DQ <encrypt>)} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<encrypt>} {($ Id.VSub_Number '$2')} {($ Id.VSub_Number '$3')}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<0>}) ] spids: [1187 1201] ) (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_GlobDEqual left: {($ Id.VSub_DollarName '$state')} right: {(DQ <decrypt>)} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<decrypt>} {($ Id.VSub_Number '$2')} {($ Id.VSub_Number '$3')}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) ] ) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<0>}) ] spids: [1221 1235] ) ] ) ] )