Date: Mon, 10 Jun 2013 12:22:35 -0700 From: Michael Sierchio <kudzu@tenebras.com> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: Bourne shell "if" syntax Message-ID: <CAHu1Y70FNX8G2ARF5zBzRbu5iMsXVkUCouBk-YruY3xH1gWsqg@mail.gmail.com> In-Reply-To: <51B62622.1070201@tundraware.com> References: <51b620a6.42f.2b6a6400.5605dcf0@go2france.com> <121701ce660c$9a9aa5b0$cfcff110$@freebsd.org> <51B62389.5000500@tundraware.com> <121b01ce660e$2abae5f0$8030b1d0$@freebsd.org> <51B62622.1070201@tundraware.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jun 10, 2013 at 12:16 PM, Tim Daneliuk <tundra@tundraware.com> wrote: > That wasn't really my point. I use sentinels because in the face of an > empty string this: > > if [ $PTR = "" ] > > Actually evaluates to: > > if [ = "" ] > > Which throws an error. Right. Many scripts seem to assume that sh is bash, and that's certainly not the case here. if [ "x$BLAH" = "x" ]; then is the most reliable and portable way of determining if it's a string of zero length. - M
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAHu1Y70FNX8G2ARF5zBzRbu5iMsXVkUCouBk-YruY3xH1gWsqg>