My current code
#!/bin/bash
#w=$2
#e=$3
#r=$4
#t=$5
#o=$5
#
prepend=""
append=""
case "$1" in
-h)
echo 'Usage: google [-{hxdw}] [<arg>]'
echo ' -h: show help.'
echo ' -x: search for "<arg> is"'
echo ' -d: search for "define:<arg>"'
echo ' -w: search for <arg> site:wikipedia.org'
exit;;
-x)
prepend="\""
append=" is\""
shift;;
-d)
prepend="\"define:"
append="\""
shift;;
-w)
prepend=""
append=" site:.wikipedia.org"
shift;;
-wo)
prepend=""
append=" site:.mathworld.wolfram.com/"
shift;;
-so)
prepend=""
append=" site:.stackoverflow.com/"
shift;;
-b)
prepend=""
append=""
shift;;
esac
if [[ -z "$1" ]] ; then # I am not sure about this line and about -z
query=""
else
query="?q=${prepend}${1}${append}${params}"
fi
# you can use echo to put the url to history, eg
# echo http://www.google.com/search${query}
open "http://www.google.com/search${query}"
I want an if-else loop for the open command such that
My unsuccessful attempt
if $1==-b; then$
open "http://www.books.google.com/search${query}"
else
open "http://www.google.com/search${query}"
fi
I get by executing the shell script with gg
gg -b "Freakonomics"
line 54: Freakonomics==-b: command not found
How can you check the value of $1 such that you can start a google-books-search in Firefox?