Wednesday, 14 August 2013

Why test for equality in sh scripts in an indirect way?

Why test for equality in sh scripts in an indirect way?

I often see this construct in sh scripts:
if [ "z$x" = z ]; then echo x is empty; fi
Why don't they just write it like this?
if [ "$x" = "" ]; then echo x is empty; fi

No comments:

Post a Comment