#!/bin/bash # Author: Alexander Epstein https://github.com/alexanderepstein global currentVersion := '"1.11.1'" global configuredClient := ''"" ## rest of these variables are search flags global search := '"0'" global insensitive := ''"" global recursive := ''"" global boundry := ''"" ## 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 } } ## 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 "Cheat" echo "Description: Cheatsheets for quick information about multiple programming languages along with terminal commands" echo "Usage: cheat [flags] [command] or cheat [flags] [programming language] [subject]" echo " -s Does a search for last argument rather than looking for exact match" echo " -i Case insensitive search" echo " -b Word boundaries in search" echo " -r Recursive search" echo " -u Update Bash-Snippet Tools" echo " -h Show the help" echo " -v Get the tool version" echo "Special Pages:" echo " hello Describes building the hello world program written in the language" echo " list This lists all cheatsheets related to previous arg if none it lists all cheatsheets" echo " learn Shows a learn-x-in-minutes language cheat sheet perfect for getting started with the language" echo " 1line A collection of one-liners in this language" echo " weirdness A collection of examples of weird things in this language" echo "Examples:" echo " cheat rust hello" echo " cheat -r -b -i go" echo " cheat julia Functions" echo " cheat -i go operators" } proc getCheatSheet { if [[ $# == 1 ]] { if [[ $search == "1" ]]{ global link := "cheat.sh/~$1" } else { global link := "cheat.sh/$1" } } else { global link := "cheat.sh/$1" } if [[ $# == 2 ]]{ if [[ $search == "1" ]]{ global link := "/~$2" ## add this to end of link where ~ indicates search } else { global link := "/$2" ## add this to end of link } } if [[ $insensitive != "" || $recursive != "" || $boundry != "" ]]{ global link := "/$boundry$insensitive$recursive"; } ## add this to the end of the link as flags httpGet $link } ### This function just wraps some of the special pages provided by cheat.sh proc checkSpecialPage { global temp := $1 if [[ $1 == "list" ]]{ global temp := '":list'" } elif [[ $1 == "learn" ]]{ global temp := '":list'" } elif [[ $1 == "styles" ]]{ global temp := '":styles'" } if [[ $2 == "1" ]]{ global arg1 := $temp } else { global arg2 := $temp } } getConfiguredClient || exit 1 checkInternet || exit 1 while getopts "ribuvhis" opt { matchstr $opt { \? { echo "Invalid option: -$OPTARG" > !2 exit 1 } h { usage exit 0 } v { echo "Version $currentVersion" exit 0 } u { update exit 0 } i { global insensitive := '"i'" global search := '"1'" } b { global boundry := '"b'" global search := '"1'" } r { global recursive := '"r'" global search := '"1'" } s { global search := '"1'" } : { echo "Option -$OPTARG requires an argument." > !2 exit 1 } } }for arg in @Argv { if [[ $arg != "-r" && $arg != "-s" && $arg != "-b" && $arg != "-i" ]]{ if test -z $(arg1+x){ global arg1 := $arg } if test ! -z $(arg1+x){ global arg2 := $arg } } } ## check for special pages before moving on checkSpecialPage $arg1 1 checkSpecialPage $arg2 2 if [[ $# == 0 ]] { usage exit 0 } elif [[ $1 == "update" ]]{ update exit 0 } elif [[ $1 == "help" || $1 == ":help" ]]{ ## shows the help and prevents the user from seeing cheat.sh/:help usage exit 0 } else { if [[ $arg1 != $arg2 ]]{ ## if they equal each other that means there was no arg 2 supplied getCheatSheet $arg1 $arg2 exit 0 } else { getCheatSheet $arg1 exit 0 } exit 0 } (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:search) op:Equal rhs:{(DQ (0))} spids:[19])] spids: [19] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:insensitive) op:Equal rhs:{(DQ )} spids:[24])] spids: [24] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:recursive) op:Equal rhs:{(DQ )} spids:[28])] spids: [28] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:boundry) op:Equal rhs:{(DQ )} spids:[32])] spids: [32] ) (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: [56] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (curl))} spids: [64] ) ] spids: [64] ) ] spids: [-1 61] ) (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: [79] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (wget))} spids: [87] ) ] spids: [87] ) ] spids: [70 84] ) (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: [102] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (fetch))} spids: [110] ) ] spids: [110] ) ] spids: [93 107] ) ] else_action: [ (C {(echo)} {(DQ ("Error: This tool reqires either curl, wget, or fetch to be installed."))} ) (ControlFlow token: arg_word:{(1)}) ] spids: [116 131] ) ] spids: [44] ) spids: [40 43] ) (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: [156 157 170 -1] ) (case_arm pat_list: [{(wget)}] action: [(C {(wget)} {(-qO-)} {(DQ ($ VSub_At "$@"))})] spids: [173 174 183 -1] ) (case_arm pat_list: [{(fetch)}] action: [(C {(fetch)} {(-o)} {(DQ (...))})] spids: [186 187 196 -1] ) ] spids: [147 153 199] ) ] spids: [144] ) spids: [140 143] ) (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: [230] ) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[234]) ] ) ] 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 254] ) ] else_action: [ (SimpleCommand words: [{(echo)} {(DQ ("Error: no active internet connection"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[274])] ) (ControlFlow token: arg_word:{(1)}) ] spids: [265 286] ) ] spids: [209] ) spids: [205 208] ) (FuncDef name: update body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:repositoryName) op: Equal rhs: {(DQ (Bash-Snippets))} spids: [310] ) ] spids: [310] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:githubUserName) op: Equal rhs: {(DQ (alexanderepstein))} spids: [319] ) ] spids: [319] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nameOfInstallFile) op: Equal rhs: {(DQ (install.sh))} spids: [328] ) ] spids: [328] ) (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: [338 374] ) } spids: [337] ) ] spids: [337] ) (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:[430])] ) (C {(exit)} {(1)}) ] spids: [-1 421] ) (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:[461])] ) (C {(exit)} {(1)}) ] spids: [439 452] ) ] 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: [558] ) ] 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: [602] ) ] op_id: Op_DPipe ) terminator: ) ] spids: [-1 590] ) ] spids: [-1 620] ) (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: [636] ) ] 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: [660] ) ] 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: [687] ) ] ) (AndOr children: [ (SimpleCommand words: [ {(git)} {(checkout)} {(DQ ($ VSub_Name "$latestVersion"))} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [701] ) ] ) (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: [755] ) ] op_id: Op_DPipe ) ] spids: [-1 549] ) ] else_action: [(C {(exit)} {(1)})] spids: [774 782] ) ] spids: [-1 490] ) ] else_action: [ (C {(echo)} {(DQ ($ VSub_Name "$repositoryName") (" is already the latest version"))} ) ] spids: [785 796] ) ] spids: [470 799] ) ] spids: [295] ) spids: [291 294] ) (FuncDef name: usage body: (BraceGroup children: [ (C {(echo)} {(DQ (Cheat))}) (C {(echo)} { (DQ ( "Description: Cheatsheets for quick information about multiple programming languages along with terminal commands" ) ) } ) (C {(echo)} { (DQ ( "Usage: cheat [flags] [command] or cheat [flags] [programming language] [subject]" ) ) } ) (C {(echo)} {(DQ (" -s Does a search for last argument rather than looking for exact match"))} ) (C {(echo)} {(DQ (" -i Case insensitive search"))}) (C {(echo)} {(DQ (" -b Word boundaries in search"))}) (C {(echo)} {(DQ (" -r Recursive search"))}) (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 ("Special Pages:"))}) (C {(echo)} {(DQ (" hello Describes building the hello world program written in the language"))} ) (C {(echo)} { (DQ ( " list This lists all cheatsheets related to previous arg if none it lists all cheatsheets" ) ) } ) (C {(echo)} { (DQ ( " learn Shows a learn-x-in-minutes language cheat sheet perfect for getting started with the language" ) ) } ) (C {(echo)} {(DQ (" 1line A collection of one-liners in this language"))}) (C {(echo)} {(DQ (" weirdness A collection of examples of weird things in this language"))}) (C {(echo)} {(DQ ("Examples:"))}) (C {(echo)} {(DQ (" cheat rust hello"))}) (C {(echo)} {(DQ (" cheat -r -b -i go"))}) (C {(echo)} {(DQ (" cheat julia Functions"))}) (C {(echo)} {(DQ (" cheat -i go operators"))}) ] spids: [809] ) spids: [805 808] ) (FuncDef name: getCheatSheet body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Pound "$#")} right: {(1)} ) ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$search")} right: {(DQ (1))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:link) op: Equal rhs: {(cheat.sh/) (Lit_Tilde "~") ($ VSub_Number "$1")} spids: [1001] ) ] spids: [1001] ) ] spids: [-1 998] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:link) op: Equal rhs: {(cheat.sh/) ($ VSub_Number "$1")} spids: [1010] ) ] spids: [1010] ) ] spids: [1007 1015] ) ] spids: [-1 981] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:link) op: Equal rhs: {(cheat.sh/) ($ VSub_Number "$1")} spids: [1021] ) ] spids: [1021] ) ] spids: [1018 1026] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Pound "$#")} right: {(2)} ) ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$search")} right: {(DQ (1))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:link) op: PlusEqual rhs: {(/) (Lit_Tilde "~") ($ VSub_Number "$2")} spids: [1062] ) ] spids: [1062] ) ] spids: [-1 1059] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:link) op: PlusEqual rhs: {(/) ($ VSub_Number "$2")} spids: [1074] ) ] spids: [1074] ) ] spids: [1071 1082] ) ] spids: [-1 1042] ) ] spids: [-1 1085] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$insensitive")} right: {(DQ )} ) right: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$recursive")} right: {(DQ )} ) right: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$boundry")} right: {(DQ )} ) ) ) ) terminator: ) ] action: [ (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:link) op: PlusEqual rhs: {(/) ($ VSub_Name "$boundry") ($ VSub_Name "$insensitive") ($ VSub_Name "$recursive") } spids: [1122] ) ] spids: [1122] ) terminator: ) ] spids: [-1 1120] ) ] spids: [-1 1129] ) (C {(httpGet)} {($ VSub_Name "$link")}) ] spids: [965] ) spids: [961 964] ) (FuncDef name: checkSpecialPage body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:temp) op: Equal rhs: {($ VSub_Number "$1")} spids: [1154] ) ] spids: [1154] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (list))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:temp) op: Equal rhs: {(DQ (":list"))} spids: [1175] ) ] spids: [1175] ) ] spids: [-1 1172] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (learn))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:temp) op: Equal rhs: {(DQ (":list"))} spids: [1198] ) ] spids: [1198] ) ] spids: [1181 1195] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (styles))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:temp) op: Equal rhs: {(DQ (":styles"))} spids: [1221] ) ] spids: [1221] ) ] spids: [1204 1218] ) ] spids: [-1 1227] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$2")} right: {(DQ (1))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:arg1) op: Equal rhs: {($ VSub_Name "$temp")} spids: [1247] ) ] spids: [1247] ) ] spids: [-1 1244] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:arg2) op: Equal rhs: {($ VSub_Name "$temp")} spids: [1254] ) ] spids: [1254] ) ] spids: [1251 1258] ) ] spids: [1151] ) spids: [1147 1150] ) (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 (ribuvhis))} {(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:[1312])] ) (C {(exit)} {(1)}) ] spids: [1301 1302 1321 -1] ) (case_arm pat_list: [{(h)}] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [1324 1325 1336 -1] ) (case_arm pat_list: [{(v)}] action: [ (C {(echo)} {(DQ ("Version ") ($ VSub_Name "$currentVersion"))}) (C {(exit)} {(0)}) ] spids: [1339 1340 1356 -1] ) (case_arm pat_list: [{(u)}] action: [(C {(update)}) (C {(exit)} {(0)})] spids: [1359 1360 1371 -1] ) (case_arm pat_list: [{(i)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:insensitive) op: Equal rhs: {(DQ (i))} spids: [1378] ) ] spids: [1378] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:search) op: Equal rhs: {(DQ (1))} spids: [1384] ) ] spids: [1384] ) ] spids: [1374 1375 1390 -1] ) (case_arm pat_list: [{(b)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:boundry) op: Equal rhs: {(DQ (b))} spids: [1397] ) ] spids: [1397] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:search) op: Equal rhs: {(DQ (1))} spids: [1403] ) ] spids: [1403] ) ] spids: [1393 1394 1409 -1] ) (case_arm pat_list: [{(r)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:recursive) op: Equal rhs: {(DQ (r))} spids: [1416] ) ] spids: [1416] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:search) op: Equal rhs: {(DQ (1))} spids: [1422] ) ] spids: [1422] ) ] spids: [1412 1413 1428 -1] ) (case_arm pat_list: [{(s)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:search) op: Equal rhs: {(DQ (1))} spids: [1435] ) ] spids: [1435] ) ] spids: [1431 1432 1441 -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:[1456])] ) (C {(exit)} {(1)}) ] spids: [1444 1445 1465 -1] ) ] spids: [1294 1298 1468] ) ] spids: [1291 1470] ) ) (ForEach iter_name: arg do_arg_iter: True body: (DoGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalAnd left: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$arg")} right: {(DQ (-r))} ) right: (LogicalAnd left: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$arg")} right: {(DQ (-s))} ) right: (LogicalAnd left: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$arg")} right: {(DQ (-b))} ) right: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$arg")} right: {(DQ (-i))} ) ) ) ) ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Plus arg_word:{(x)}) spids: [1536 1540] ) } {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:arg1) op: Equal rhs: {($ VSub_Name "$arg")} spids: [1547] ) ] spids: [1547] ) ] spids: [-1 1544] ) ] spids: [-1 1551] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-z)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Plus arg_word:{(x)}) spids: [1562 1566] ) } {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:arg2) op: Equal rhs: {($ VSub_Name "$arg")} spids: [1573] ) ] spids: [1573] ) ] spids: [-1 1570] ) ] spids: [-1 1577] ) ] spids: [-1 1527] ) ] spids: [-1 1580] ) ] spids: [1480 1582] ) spids: [-1 -1] ) (C {(checkSpecialPage)} {($ VSub_Name "$arg1")} {(1)}) (C {(checkSpecialPage)} {($ VSub_Name "$arg2")} {(2)}) (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 1614] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (update))} ) ) terminator: ) ] action: [(C {(update)}) (C {(exit)} {(0)})] spids: [1624 1638] ) (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (help))} ) right: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (":help"))} ) ) ) terminator: ) ] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [1648 1672] ) ] else_action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$arg1")} right: {($ VSub_Name "$arg2")} ) ) terminator: ) ] action: [ (C {(getCheatSheet)} {($ VSub_Name "$arg1")} {($ VSub_Name "$arg2")}) (C {(exit)} {(0)}) ] spids: [-1 1700] ) ] else_action: [(C {(getCheatSheet)} {($ VSub_Name "$arg1")}) (C {(exit)} {(0)})] spids: [1718 1731] ) (C {(exit)} {(0)}) ] spids: [1685 1739] ) ] )