Groups
Groups
Sign in
Groups
Groups
bash tips
Conversations
About
Send feedback
Help
Testing for Executables
13 views
Skip to first unread message
Joaquin Menchaca
unread,
Nov 13, 2015, 7:17:01 PM
11/13/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to bash tips
I did this, but is there a cleaner way?
[ -z $(which wget) ] && { echo "ERROR: Wget not found. Install wget"; exit 1 ; }
RJ
unread,
Nov 15, 2015, 1:53:55 AM
11/15/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to bash tips
I would recommend not writing it all in one line (
https://google.github.io/styleguide/shell.xml
)
What about:
which wget 2>&1 >/dev/null
code=$?
if [[ $code -ne 0 ]]; then
echo "ERROR: Wget not found. Install wget"
exit $code
fi
However, if you must do it on one line:
[[ $(which wget) ]] && { echo "ERROR: Wget not found. Install wget"; exit 1; }
Reply all
Reply to author
Forward
0 new messages