Fixing the $@ by double quoting to prevent word splitting

This commit is contained in:
Alex Epstein 2017-07-03 18:40:22 -04:00
parent eb7b5c2001
commit 82219534c4
4 changed files with 8 additions and 8 deletions

View File

@ -47,7 +47,7 @@ checkInternet()
getMovieInfo()
{
apiKey=946f500a # try not to abuse this it is a key that came from the ruby-scripts repo I link to.
movie=$(echo $@ | tr " " + ) ## format the inputs to use for the api
movie=$(echo "$@" | tr " " + ) ## format the inputs to use for the api
export PYTHONIOENCODING=utf8 #necessary for python2 in some cases
movieInfo=$(httpGet "http://www.omdbapi.com/?t=$movie&apikey=$apiKey") > /dev/null # query the server and get the JSON response
checkResponse=$(echo $movieInfo | python2 -c "import sys, json; print json.load(sys.stdin)['Response']")
@ -167,6 +167,6 @@ elif [[ $1 == "update" ]];then
elif [[ $1 == "help" ]];then
usage
else
getMovieInfo $@ || exit 1 ## exit if we return 1 (chances are movie was not found)
getMovieInfo "$@" || exit 1 ## exit if we return 1 (chances are movie was not found)
printMovieInfo ## print out the data
fi

View File

@ -183,7 +183,7 @@ elif [[ $# == "0" ]];then
usage
exit 0
else
getTicker $@ # the company name might have spaces so passing in all args allows for this
getTicker "$@" # the company name might have spaces so passing in all args allows for this
getStockInformation $symbol # based on the stock symbol exrapolated by the getTicker function get information on the stock
printStockInformation # print this information out to the user in a human readable format
exit 0

View File

@ -238,14 +238,14 @@ elif [[ $1 == "help" ]];then
else
if [[ $search == "0" ]];then
if [[ $info == "0" ]];then
getSimilar $@ || exit 1 ## exit if we return 1 (chances are movie was not found)
getSimilar "$@" || exit 1 ## exit if we return 1 (chances are movie was not found)
printResults
else
getSimilar $@ || exit 1
getSimilar "$@" || exit 1
printResults
fi
else
getInfo ${@:2} || exit 1 ## exit if we return 1 (chances are movie was not found)
getInfo "${@:2}" || exit 1 ## exit if we return 1 (chances are movie was not found)
printInfo
fi
fi

View File

@ -49,7 +49,7 @@ getIPWeather()
getLocationWeather()
{
args=$(echo $@ | tr " " + )
args=$(echo "$@" | tr " " + )
httpGet $locale.wttr.in/${args}
}
@ -159,5 +159,5 @@ elif [[ $1 == "m" ]]; then
elif [[ $1 == "i" ]]; then
getIPWeather "?u"
else
getLocationWeather $@
getLocationWeather "$@"
fi