#!/bin/bash # Author: Alexander Epstein https://github.com/alexanderepstein global currentVersion := '"1.11.1'" #This version variable should not have a v but should contain all other characters ex Github release tag is v1.2.4 currentVersion is 1.2.4 global LANG := $(LANG:-en) global locale := $[echo $LANG | cut -c1-2] global configuredClient := ''"" ## 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 getIPWeather { global country := $[httpGet ipinfo.io/country] > /dev/null ## grab the country if [[ $country == "US" ]]{ ## if were in the us id rather not use longitude and latitude so the output is nicer global city := $[httpGet ipinfo.io/city] > /dev/null global region := $[httpGet ipinfo.io/region] > /dev/null global region := $[echo $region | tr -dc '[:upper:]] httpGet $locale.wttr.in/$city,$region$1 } else { ## otherwise we are going to use longitude and latitude global location := $[httpGet ipinfo.io/loc] > /dev/null httpGet $locale.wttr.in/$location$1 } } proc getLocationWeather { global args := $[echo @Argv | tr " " +] httpGet $locale.wttr.in/$(args) } proc checkInternet { echo "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 "Weather" echo "Description: Provides a 3 day forecast on your current location or a specified location." echo " With no flags Weather will default to your current location." echo "Usage: weather or weather [flag] or weather [country] or weather [city] [state]" echo " weather [i] get weather in imperial units" echo " weather [m] get weather in metric units" echo " weather [Moon] grabs the phase of the moon" echo " -u Update Bash-Snippet Tools" echo " -h Show the help" echo " -v Get the tool version" echo "Examples:" echo " weather" echo " weather Tokyo" echo " weather Moon" echo " weather m" } getConfiguredClient || exit 1 checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here 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" ]] { getIPWeather } elif [[ $1 == "help" ]]{ usage } elif [[ $1 == "update" ]] { update } elif [[ $1 == "m" ]] { getIPWeather "?m" } elif [[ $1 == "i" ]] { getIPWeather "?u" } else { getLocationWeather @Argv } (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:LANG) op: Equal rhs: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(en)}) spids: [17 21] ) ) } spids: [15] ) ] spids: [15] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:locale) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [(C {(echo)} {($ VSub_Name "$LANG")}) (C {(cut)} {(-c1-2)})] negated: False ) ] ) left_token: spids: [25 35] ) } spids: [24] ) ] spids: [24] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:configuredClient) op:Equal rhs:{(DQ )} spids:[37])] spids: [37] ) (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: [61] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (curl))} spids: [69] ) ] spids: [69] ) ] spids: [-1 66] ) (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: [84] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (wget))} spids: [92] ) ] spids: [92] ) ] spids: [75 89] ) (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: [107] ) ] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (fetch))} spids: [115] ) ] spids: [115] ) ] spids: [98 112] ) ] else_action: [ (C {(echo)} {(DQ ("Error: This tool reqires either curl, wget, or fetch to be installed."))} ) (ControlFlow token: arg_word:{(1)}) ] spids: [121 136] ) ] spids: [49] ) spids: [45 48] ) (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: [161 162 175 -1] ) (case_arm pat_list: [{(wget)}] action: [(C {(wget)} {(-qO-)} {(DQ ($ VSub_At "$@"))})] spids: [178 179 188 -1] ) (case_arm pat_list: [{(fetch)}] action: [(C {(fetch)} {(-o)} {(DQ (...))})] spids: [191 192 201 -1] ) ] spids: [152 158 204] ) ] spids: [149] ) spids: [145 148] ) (FuncDef name: getIPWeather body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:country) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(httpGet)} {(ipinfo.io/country)})]) left_token: spids: [218 222] ) } spids: [217] ) ] spids: [217] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$country")} right: {(DQ (US))} ) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:city) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(httpGet)} {(ipinfo.io/city)})] ) left_token: spids: [253 257] ) } spids: [252] ) ] spids: [252] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:region) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(httpGet)} {(ipinfo.io/region)})] ) left_token: spids: [265 269] ) } spids: [264] ) ] spids: [264] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:region) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_Name "$region"))}) (C {(tr)} {(-dc)} {(SQ <"[:upper:]">)}) ] negated: False ) ] ) left_token: spids: [277 293] ) } spids: [276] ) ] spids: [276] ) (C {(httpGet)} {($ VSub_Name "$locale") (.wttr.in/) ($ VSub_Name "$city") (Lit_Comma ",") ($ VSub_Name "$region") ($ VSub_Number "$1") } ) ] spids: [-1 246] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:location) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(httpGet)} {(ipinfo.io/loc)})]) left_token: spids: [313 317] ) } spids: [312] ) ] spids: [312] ) (C {(httpGet)} {($ VSub_Name "$locale") (.wttr.in/) ($ VSub_Name "$location") ($ VSub_Number "$1")} ) ] spids: [306 332] ) ] spids: [214] ) spids: [210 213] ) (FuncDef name: getLocationWeather body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:args) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_At "$@"))}) (C {(tr)} {(DQ (" "))} {(Lit_Other "+")}) ] negated: False ) ] ) left_token: spids: [345 362] ) } spids: [344] ) ] spids: [344] ) (C {(httpGet)} {($ VSub_Name "$locale") (.wttr.in/) (${ VSub_Name args)}) ] spids: [341] ) spids: [337 340] ) (FuncDef name: checkInternet body: (BraceGroup children: [ (Pipeline children: [ (C {(echo)} { (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: [399] ) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[403]) ] ) ] 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 423] ) ] else_action: [ (SimpleCommand words: [{(echo)} {(DQ ("Error: no active internet connection"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[443])] ) (ControlFlow token: arg_word:{(1)}) ] spids: [434 455] ) ] spids: [380] ) spids: [376 379] ) (FuncDef name: update body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:repositoryName) op: Equal rhs: {(DQ (Bash-Snippets))} spids: [479] ) ] spids: [479] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:githubUserName) op: Equal rhs: {(DQ (alexanderepstein))} spids: [488] ) ] spids: [488] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nameOfInstallFile) op: Equal rhs: {(DQ (install.sh))} spids: [497] ) ] spids: [497] ) (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: [507 543] ) } spids: [506] ) ] spids: [506] ) (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:[599])] ) (C {(exit)} {(1)}) ] spids: [-1 590] ) (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:[630])] ) (C {(exit)} {(1)}) ] spids: [608 621] ) ] 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: [727] ) ] 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: [771] ) ] op_id: Op_DPipe ) terminator: ) ] spids: [-1 759] ) ] spids: [-1 789] ) (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: [805] ) ] 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: [829] ) ] 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: [856] ) ] ) (AndOr children: [ (SimpleCommand words: [ {(git)} {(checkout)} {(DQ ($ VSub_Name "$latestVersion"))} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [870] ) ] ) (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: [924] ) ] op_id: Op_DPipe ) ] spids: [-1 718] ) ] else_action: [(C {(exit)} {(1)})] spids: [943 951] ) ] spids: [-1 659] ) ] else_action: [ (C {(echo)} {(DQ ($ VSub_Name "$repositoryName") (" is already the latest version"))} ) ] spids: [954 965] ) ] spids: [639 968] ) ] spids: [464] ) spids: [460 463] ) (FuncDef name: usage body: (BraceGroup children: [ (C {(echo)} {(DQ (Weather))}) (C {(echo)} { (DQ ( "Description: Provides a 3 day forecast on your current location or a specified location." ) ) } ) (C {(echo)} {(DQ (" With no flags Weather will default to your current location."))}) (C {(echo)} { (DQ ( "Usage: weather or weather [flag] or weather [country] or weather [city] [state]" ) ) } ) (C {(echo)} {(DQ (" weather [i] get weather in imperial units"))}) (C {(echo)} {(DQ (" weather [m] get weather in metric units"))}) (C {(echo)} {(DQ (" weather [Moon] grabs the phase of the moon"))}) (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 (" weather"))}) (C {(echo)} {(DQ (" weather Tokyo"))}) (C {(echo)} {(DQ (" weather Moon"))}) (C {(echo)} {(DQ (" weather m"))}) ] spids: [978] ) spids: [974 977] ) (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:[1143])] ) (C {(exit)} {(1)}) ] spids: [1132 1133 1152 -1] ) (case_arm pat_list: [{(h)}] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [1155 1156 1167 -1] ) (case_arm pat_list: [{(v)}] action: [ (C {(echo)} {(DQ ("Version ") ($ VSub_Name "$currentVersion"))}) (C {(exit)} {(0)}) ] spids: [1170 1171 1187 -1] ) (case_arm pat_list: [{(u)}] action: [(C {(update)}) (C {(exit)} {(0)})] spids: [1190 1191 1202 -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:[1217])] ) (C {(exit)} {(1)}) ] spids: [1205 1206 1226 -1] ) ] spids: [1125 1129 1229] ) ] spids: [1122 1231] ) ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Pound "$#")} right: {(DQ (0))} ) ) terminator: ) ] action: [(C {(getIPWeather)})] spids: [-1 1249] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (help))} ) ) terminator: ) ] action: [(C {(usage)})] spids: [1254 1268] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (update))} ) ) terminator: ) ] action: [(C {(update)})] spids: [1273 1288] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (m))} ) ) terminator: ) ] action: [(C {(getIPWeather)} {(DQ ("?m"))})] spids: [1293 1308] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (i))} ) ) terminator: ) ] action: [(C {(getIPWeather)} {(DQ ("?u"))})] spids: [1317 1332] ) ] else_action: [(C {(getLocationWeather)} {(DQ ($ VSub_At "$@"))})] spids: [1341 1350] ) ] )