ot, bash programming question
greg at romuald.net.eu.org
Thu Mar 29 02:45:17 EDT 2012
-----BEGIN PGP SIGNED MESSAGE-----
apologies for the off topic post, but I'm hoping someone can answer my
In a bash script, how do you deal with a program returning 0 in an if
Here's a script to illustrate what I mean
if [ `/bin/true || echo $?` = 1 ] ; then
echo "returned 1"
When I run this, I should just get the bash prompt back. When I run it
though, I get:
[: 4: =: unexpected operator
followed by the prompt.
I understand this happens because true exits with 0 status, and it
isn't echoed back, so the if statement compares nothing to 1. What I'd
like to know is how to get around that? Thanks in advance.
web site: http://www.romuald.net.eu.org
gpg public key: http://www.romuald.net.eu.org/pubkey.asc
(authorization required, add me to your contacts list first)
Free domains: http://www.eu.org/ or mail dns-manager at EU.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the Speakup