Bourne shell "if" syntax
Michael Sierchio
kudzu at tenebras.com
Mon Jun 10 19:22:36 UTC 2013
On Mon, Jun 10, 2013 at 12:16 PM, Tim Daneliuk <tundra at 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
More information about the freebsd-questions
mailing list