#!/bin/bash # Author: Alexander Epstein https://github.com/alexanderepstein global currentVersion := '"1.11.1'" global configuredClient := ''"" global configuredPython := ''"" ## This function determines which http get tool the system has installed and returns an error if there isnt one proc getConfiguredClient { if command -v curl &>/dev/null ; { global configuredClient := '"curl'" } elif command -v wget &>/dev/null ; { global configuredClient := '"wget'" } elif command -v fetch &>/dev/null ; { global configuredClient := '"fetch'" } else { echo "Error: This tool reqires either curl, wget, or fetch to be installed." return 1 } } proc getConfiguredPython { if command -v python2 &>/dev/null ; { global configuredPython := '"python2'" } elif command -v python &>/dev/null ; { global configuredPython := '"python'" } else { echo "Error: This tool requires python 2 to be installed." return 1 } } proc python { matchstr $configuredPython { python2 { python2 @Argv} python { python @Argv} } } ## Allows to call the users configured client without if statements everywhere proc httpGet { matchstr $configuredClient { curl { curl -A curl -s @Argv} wget { wget -qO- @Argv} fetch { fetch -o "..."} } } proc checkInternet { echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null !2 > !1 # query google with a get request if test $Status -eq 0 { #check if the output is 0, if so no errors have occured and we have connected to google successfully return 0 } else { echo "Error: no active internet connection" > !2 #sent to stderr return 1 } } proc update { # Author: Alexander Epstein https://github.com/alexanderepstein # Update utility version 1.2.0 # To test the tool enter in the defualt values that are in the examples for each variable global repositoryName := '"Bash-Snippets'" #Name of repostiory to be updated ex. Sandman-Lite global githubUserName := '"alexanderepstein'" #username that hosts the repostiory ex. alexanderepstein global nameOfInstallFile := '"install.sh'" # change this if the installer file has a different name be sure to include file extension if there is one global latestVersion := $[httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+] #always grabs the tag without the v option if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]]{ echo "Error: update utility has not been configured correctly." > !2 exit 1 } elif [[ $latestVersion == "" ]]{ echo "Error: no active internet connection" > !2 exit 1 } else { if [[ "$latestVersion" != "$currentVersion" ]] { echo "Version $latestVersion available" echo -n "Do you wish to update $repositoryName [Y/n]: " read -r answer if [[ "$answer" == "Y" || "$answer" == "y" ]] { cd ~ || do { echo 'Update Failed' ; exit 1 ; } if [[ -d ~/$repositoryName ]] { rm -r -f $repositoryName || do { echo "Permissions Error: try running the update as sudo"; exit 1; } ; } git clone "https://github.com/$githubUserName/$repositoryName" || do { echo "Couldn't download latest version" ; exit 1; } cd $repositoryName || do { echo 'Update Failed' ; exit 1 ;} git checkout "v$latestVersion" !2 > /dev/null || git checkout $latestVersion !2 > /dev/null || echo "Couldn't git checkout to stable release, updating to latest commit." chmod a+x install.sh #this might be necessary in your case but wasnt in mine. ./$nameOfInstallFile "update" || exit 1 cd .. rm -r -f $repositoryName || do { echo "Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo"; exit 1; } } else { exit 1 } } else { echo "$repositoryName is already the latest version" } } } proc usage { echo "Short" echo "Description: Unmasks shortended urls." echo "Usage: short [shortURL] or short [flag]" echo " -u Update Bash-Snippet Tools" echo " -h Show the help" echo " -v Get the tool version" echo "Example:" echo " Input: short tinyurl.com/jhkj" echo " Output: http://possiblemaliciouswebsiteornot.com" } proc expandURL { global testURL := $[ echo $1 | cut -c1-8] if [[ $testURL != "https://" ]]{ global testURL := $[ echo $1 | cut -c1-7] if [[ $testURL != "http://" ]]{ global url := ""http://$1"" } else { global url := $1 } } else { global url := $1 } global response := $[httpGet http://x.datasig.io/short?url=$url] global errorCheck := $[echo $response | python -c "import sys, json; print json.load(sys.stdin)['/short']['message']" !2 > /dev/null] if [[ $errorCheck == "Error in /short" ]]{ echo "Error: 404 could not find the website" return 1 } global expandedURL := $[echo $response | python -c "import sys, json; print json.load(sys.stdin)['/short']['destination']" !2 > /dev/null] } proc printResults { echo "=====================================================================" echo "Short URL: $url" echo "Expanded URL: $expandedURL" echo "=====================================================================" } getConfiguredPython || exit 1 getConfiguredClient || exit 1 checkInternet || exit 1 while getopts "uvh" opt { matchstr $opt { \? { echo "Invalid option: -$OPTARG" > !2 exit 1 } h { usage exit 0 } v { echo "Version $currentVersion" exit 0 } u { update exit 0 } : { echo "Option -$OPTARG requires an argument." > !2 exit 1 } } } if [[ $# == 0 ]] { usage exit 0 } elif [[ $# == "1" ]] { if [[ $1 == "update" ]]{ update } elif [[ $1 == "help" ]] { usage } else { expandURL $1 || exit 1 printResults } } else { echo "Error: short only accepts one argument" exit 1 } (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:configuredClient) op:Equal rhs:{(DQ )} spids:[12])] spids: [12] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:configuredPython) op:Equal rhs:{(DQ )} spids:[16])] spids: [16] ) (FuncDef name: getConfiguredClient body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(command)} {(-v)} {(curl)}) terminator: ) (Sentence child: (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [40] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (curl))} spids: [48] ) ] spids: [48] ) ] spids: [-1 45] ) (if_arm cond: [ (Sentence child: (C {(command)} {(-v)} {(wget)}) terminator: ) (Sentence child: (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [63] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (wget))} spids: [71] ) ] spids: [71] ) ] spids: [54 68] ) (if_arm cond: [ (Sentence child: (C {(command)} {(-v)} {(fetch)}) terminator: ) (Sentence child: (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [86] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (fetch))} spids: [94] ) ] spids: [94] ) ] spids: [77 91] ) ] else_action: [ (C {(echo)} {(DQ ("Error: This tool reqires either curl, wget, or fetch to be installed."))} ) (ControlFlow token: arg_word:{(1)}) ] spids: [100 115] ) ] spids: [28] ) spids: [24 27] ) (FuncDef name: getConfiguredPython body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(command)} {(-v)} {(python2)}) terminator: ) (Sentence child: (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [138] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredPython) op: Equal rhs: {(DQ (python2))} spids: [146] ) ] spids: [146] ) ] spids: [-1 143] ) (if_arm cond: [ (Sentence child: (C {(command)} {(-v)} {(python)}) terminator: ) (Sentence child: (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [161] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredPython) op: Equal rhs: {(DQ (python))} spids: [169] ) ] spids: [169] ) ] spids: [152 166] ) ] else_action: [ (C {(echo)} {(DQ ("Error: This tool requires python 2 to be installed."))}) (ControlFlow token: arg_word:{(1)}) ] spids: [175 190] ) ] spids: [126] ) spids: [122 125] ) (FuncDef name: python body: (BraceGroup children: [ (Case to_match: {(DQ ($ VSub_Name "$configuredPython"))} arms: [ (case_arm pat_list: [{(python2)}] action: [(C {(python2)} {(DQ ($ VSub_At "$@"))})] spids: [212 213 220 -1] ) (case_arm pat_list: [{(python)}] action: [(C {(python)} {(DQ ($ VSub_At "$@"))})] spids: [223 224 231 -1] ) ] spids: [203 209 234] ) ] spids: [200] ) spids: [196 199] ) (FuncDef name: httpGet body: (BraceGroup children: [ (Case to_match: {(DQ ($ VSub_Name "$configuredClient"))} arms: [ (case_arm pat_list: [{(curl)}] action: [(C {(curl)} {(-A)} {(curl)} {(-s)} {(DQ ($ VSub_At "$@"))})] spids: [258 259 272 -1] ) (case_arm pat_list: [{(wget)}] action: [(C {(wget)} {(-qO-)} {(DQ ($ VSub_At "$@"))})] spids: [275 276 285 -1] ) (case_arm pat_list: [{(fetch)}] action: [(C {(fetch)} {(-o)} {(DQ (...))})] spids: [288 289 298 -1] ) ] spids: [249 255 301] ) ] spids: [246] ) spids: [242 245] ) (FuncDef name: checkInternet body: (BraceGroup children: [ (Pipeline children: [ (C {(echo)} {(-e)} { (DQ ("GET http://google.com HTTP/1.0") (EscapedLiteralPart token:) (EscapedLiteralPart token:) ) } ) (SimpleCommand words: [{(nc)} {(google.com)} {(80)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [331] ) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[335]) ] ) ] negated: False ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_QMark "$?")} {(-eq)} {(0)} {(Lit_Other "]")}) terminator: ) ] action: [(ControlFlow token: arg_word:{(0)})] spids: [-1 355] ) ] else_action: [ (SimpleCommand words: [{(echo)} {(DQ ("Error: no active internet connection"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[375])] ) (ControlFlow token: arg_word:{(1)}) ] spids: [366 387] ) ] spids: [310] ) spids: [306 309] ) (FuncDef name: update body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:repositoryName) op: Equal rhs: {(DQ (Bash-Snippets))} spids: [411] ) ] spids: [411] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:githubUserName) op: Equal rhs: {(DQ (alexanderepstein))} spids: [420] ) ] spids: [420] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nameOfInstallFile) op: Equal rhs: {(DQ (install.sh))} spids: [429] ) ] spids: [429] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:latestVersion) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(httpGet)} {(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: spids: [439 475] ) } spids: [438] ) ] spids: [438] ) (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: ) ] action: [ (SimpleCommand words: [ {(echo)} {(DQ ("Error: update utility has not been configured correctly."))} ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[531])] ) (C {(exit)} {(1)}) ] spids: [-1 522] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$latestVersion")} right: {(DQ )} ) ) terminator: ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Error: no active internet connection"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[562])] ) (C {(exit)} {(1)}) ] spids: [540 553] ) ] 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: ) ] 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: ) ] action: [ (AndOr children: [ (C {(cd)} {(TildeSubPart prefix:"")}) (BraceGroup children: [ (Sentence child: (C {(echo)} {(SQ <"Update Failed">)}) terminator: ) (Sentence child: (C {(exit)} {(1)}) terminator: ) ] spids: [659] ) ] 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: ) ] 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: ) (Sentence child: (C {(exit)} {(1)}) terminator: ) ] spids: [703] ) ] op_id: Op_DPipe ) terminator: ) ] spids: [-1 691] ) ] spids: [-1 721] ) (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: ) (Sentence child: (C {(exit)} {(1)}) terminator: ) ] spids: [737] ) ] op_id: Op_DPipe ) (AndOr children: [ (C {(cd)} {($ VSub_Name "$repositoryName")}) (BraceGroup children: [ (Sentence child: (C {(echo)} {(SQ <"Update Failed">)}) terminator: ) (Sentence child: (C {(exit)} {(1)}) terminator: ) ] spids: [761] ) ] 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: [788] ) ] ) (AndOr children: [ (SimpleCommand words: [ {(git)} {(checkout)} {(DQ ($ VSub_Name "$latestVersion"))} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [802] ) ] ) (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: ) (Sentence child: (C {(exit)} {(1)}) terminator: ) ] spids: [856] ) ] op_id: Op_DPipe ) ] spids: [-1 650] ) ] else_action: [(C {(exit)} {(1)})] spids: [875 883] ) ] spids: [-1 591] ) ] else_action: [ (C {(echo)} {(DQ ($ VSub_Name "$repositoryName") (" is already the latest version"))} ) ] spids: [886 897] ) ] spids: [571 900] ) ] spids: [396] ) spids: [392 395] ) (FuncDef name: usage body: (BraceGroup children: [ (C {(echo)} {(DQ (Short))}) (C {(echo)} {(DQ ("Description: Unmasks shortended urls."))}) (C {(echo)} {(DQ ("Usage: short [shortURL] or short [flag]"))}) (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 ("Example:"))}) (C {(echo)} {(DQ (" Input: short tinyurl.com/jhkj"))}) (C {(echo)} {(DQ (" Output: http://possiblemaliciouswebsiteornot.com"))}) ] spids: [909] ) spids: [905 908] ) (FuncDef name: expandURL body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:testURL) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [(C {(echo)} {($ VSub_Number "$1")}) (C {(cut)} {(-c1-8)})] negated: False ) ] ) left_token: spids: [985 997] ) } spids: [984] ) ] spids: [984] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$testURL")} right: {(DQ ("https://"))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:testURL) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Number "$1")}) (C {(cut)} {(-c1-7)}) ] negated: False ) ] ) left_token: spids: [1018 1030] ) } spids: [1017] ) ] spids: [1017] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$testURL")} right: {(DQ ("http://"))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:url) op: Equal rhs: {(DQ ("http://") ($ VSub_Number "$1"))} spids: [1050] ) ] spids: [1050] ) ] spids: [-1 1047] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:url) op: Equal rhs: {($ VSub_Number "$1")} spids: [1060] ) ] spids: [1060] ) ] spids: [1057 1064] ) ] spids: [-1 1014] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:url) op: Equal rhs: {($ VSub_Number "$1")} spids: [1070] ) ] spids: [1070] ) ] spids: [1067 1074] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:response) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(httpGet)} {(http) (Lit_Other ":") (//x.datasig.io/short) (Lit_Other "?") (Lit_VarLike "url=") ($ VSub_Name "$url") } ) ] ) left_token: spids: [1078 1087] ) } spids: [1077] ) ] spids: [1077] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:errorCheck) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$response")}) (SimpleCommand words: [ {(python)} {(-c)} { (DQ ( "import sys, json; print json.load(sys.stdin)['/short']['message']" ) ) } ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [1106] ) ] ) ] negated: False ) ] ) left_token: spids: [1091 1110] ) } spids: [1090] ) ] spids: [1090] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$errorCheck")} right: {(DQ ("Error in /short"))} ) ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Error: 404 could not find the website"))}) (ControlFlow token: arg_word:{(1)}) ] spids: [-1 1127] ) ] spids: [-1 1141] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:expandedURL) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$response")}) (SimpleCommand words: [ {(python)} {(-c)} { (DQ ( "import sys, json; print json.load(sys.stdin)['/short']['destination']" ) ) } ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [1160] ) ] ) ] negated: False ) ] ) left_token: spids: [1145 1164] ) } spids: [1144] ) ] spids: [1144] ) ] spids: [981] ) spids: [977 980] ) (FuncDef name: printResults body: (BraceGroup children: [ (C {(echo)} {(DQ ("====================================================================="))}) (C {(echo)} {(DQ ("Short URL: ") ($ VSub_Name "$url"))}) (C {(echo)} {(DQ ("Expanded URL: ") ($ VSub_Name "$expandedURL"))}) (C {(echo)} {(DQ ("====================================================================="))}) ] spids: [1174] ) spids: [1170 1173] ) (AndOr children:[(C {(getConfiguredPython)})(C {(exit)} {(1)})] op_id:Op_DPipe) (AndOr children:[(C {(getConfiguredClient)})(C {(exit)} {(1)})] op_id:Op_DPipe) (AndOr children:[(C {(checkInternet)})(C {(exit)} {(1)})] op_id:Op_DPipe) (While cond: [(Sentence child:(C {(getopts)} {(DQ (uvh))} {(opt)}) terminator:)] body: (DoGroup children: [ (Case to_match: {($ VSub_Name "$opt")} arms: [ (case_arm pat_list: [{(EscapedLiteralPart token:)}] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Invalid option: -") ($ VSub_Name "$OPTARG"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[1266])] ) (C {(exit)} {(1)}) ] spids: [1255 1256 1275 -1] ) (case_arm pat_list: [{(h)}] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [1278 1279 1290 -1] ) (case_arm pat_list: [{(v)}] action: [ (C {(echo)} {(DQ ("Version ") ($ VSub_Name "$currentVersion"))}) (C {(exit)} {(0)}) ] spids: [1293 1294 1310 -1] ) (case_arm pat_list: [{(u)}] action: [(C {(update)}) (C {(exit)} {(0)})] spids: [1313 1314 1325 -1] ) (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:-1 arg_word:{(2)} spids:[1340])] ) (C {(exit)} {(1)}) ] spids: [1328 1329 1349 -1] ) ] spids: [1248 1252 1352] ) ] spids: [1245 1354] ) ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_GlobDEqual left:{($ VSub_Pound "$#")} right:{(0)}) ) terminator: ) ] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [-1 1371] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Pound "$#")} right: {(DQ (1))} ) ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (update))} ) ) terminator: ) ] action: [(C {(update)})] spids: [-1 1413] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (help))} ) ) terminator: ) ] action: [(C {(usage)})] spids: [1419 1434] ) ] else_action: [ (AndOr children: [(C {(expandURL)} {($ VSub_Number "$1")}) (C {(exit)} {(1)})] op_id: Op_DPipe ) (C {(printResults)}) ] spids: [1440 1457] ) ] spids: [1381 1396] ) ] else_action: [(C {(echo)} {(DQ ("Error: short only accepts one argument"))}) (C {(exit)} {(1)})] spids: [1459 1473] ) ] )