[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Simple shell scripting question from a newbie.



Henning:

||  Scripsit zweije@xs4all.nl (Vincent Zweije)

||  > I would write [ "${1:+x}" ], or rather even [ "${1+x}" ], distinguishing
||  > empty and undefined.
||
||  Wouldn't work. Most shells (and /bin/['s) are fine with empty
||  arguments, but some get confused if the first character of the
||  argument is a dash, such that it can be interpreted as an option.
||  Hence the 'x' in front.

No leading dash occurs in these two examples. The substitutions yield
either "x" or "", depending on $1. But we're digressing.

The compatibility argument that was mentioned explains why avoiding -z
would be better. I don't know if there are compatibility problems when
using ${var+value}.

Ciao.                                                         Vincent.

Attachment: signature.asc
Description: Digital signature


Reply to: