Re: /etc/shells management
On 08-Sep-03, 03:42 (CDT), Branden Robinson <branden@debian.org> wrote:
> I personally stongly advocate -n and -z over [ "$var" ] and really
> horrible tests like:
>
> if [ "x$var" = "x" ]
> and
> if [ "x$var" != "x" ]
>
> Those just strike me as obscurantist (which might explain why they
> feature prominently in shell scripts by Ian Jackson, heh).
Probably because Ian learned shell scripting in the days (or from
scripts written in those days) when
[ "$var" = "foo" ]
was likely to cause problems when $var was undefined. So we learned to do
[ "X$var" = "Xfoo" ]
which leads to using '[ "X$foo" = "X" ]' to test for empty.
Steve
--
Steve Greenland
The irony is that Bill Gates claims to be making a stable operating
system and Linus Torvalds claims to be trying to take over the
world. -- seen on the net
Reply to: