-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 I'm not quite sure what you're asking, maybe this is it. True returns 0 by default, so you can just do: if true;then echo it succeeded fi But from your example script, maybe you wanted: if ! true;then echo it failed fi On 3/28/2012 11:45 PM, Gregory Nowak wrote: > Hi folks, > > apologies for the off topic post, but I'm hoping someone can answer > my question. > > In a bash script, how do you deal with a program returning 0 in an > if statement? Here's a script to illustrate what I mean > > #!/bin/sh if [ `/bin/true || echo $?` = 1 ] ; then echo "returned > 1" fi > > 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. > > Greg > > > _______________________________________________ Speakup mailing > list Speakup at braille.uwo.ca > http://speech.braille.uwo.ca/mailman/listinfo/speakup -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBCgAGBQJPdA40AAoJEPb0SlyudCqvnMkQAJGHpEMH0pBMWp9Lo3aW52h2 kOG/xS3Ix//9W75WmYHDmKGitwW7srvTlOHNXVi5Y275GaVtpwxgGEnkJNfTvPyj mlvEagFBOfBfWfreUGD3bAEYWodS5k/2MtQqVx8j9AGtylETq2UewBDshitEP3xP 0zeCmhJUbomm6XY2RZ8nkAoku6S59ax3SPdCadredym2ng1pRyyLCapd0SXGTRyE w9WLShff0tgOCDYyo13fzJlJC81YDpWXSv4N4VZpqA/9kjehfTBhSB7mn6sTVPnB R6tG49X0MPyAHnA/WVWZrIKVzMNLdxILxgt1LPaMBmBdgW0McYQqysYRar7H/qTw cb9rm8ORPMtpku+4B43ZMt0hH2fNbilRAd5xhdqWD0kDVmdviNvDEJQRU7YUCLWA n48Y6nkD482fAMrGeBDcVzi+NHP3SP5ZecLXQ8ijagJpXFfhrR9FK5btpQIzmrvQ 4PJZcHfnimbYBOWlvUVJSh7AwPIRG8Jqv1T8HUJS60qeCCWATT49tqHv4WgurxXN cifWTZN8UzTCm2bBsiTqCSY/K2T4ISo8ySzMijabdj1WqJ1OXPceemG+o8OVOkR/ VIzm+dAFlVtbwKzuI/N/loxZUzM7K11EgKiI509PjUgsoffMpl/Zr3V4B52KacvH RsL98yPEvfeBk0Id0fw1 =S3vJ -----END PGP SIGNATURE-----