[Orca-users] orca 0.27 make error on Solaris 9
Adam R Prato
arp at pra.to
Mon Aug 30 16:38:26 PDT 2004
* Blair Zajac wrote on 30 Aug 2004:
> Adam R Prato wrote:
>
> >* Blair Zajac wrote on 30 Aug 2004:
> >
> >
> >
> >>This little test
> >>
> >>a=" "
> >>if test ! -z $a; then
> >> echo not empty
> >>fi
> >>
> >>works fine using /bin/sh on Linux, but with Solaris' /bin/sh, I get this:
> >>
> >>test.sh: test: argument expected
> >>
> >>so it doesn't work. I think the echo is the most portable, easy way to
> >>solve this problem.
> >>
> >>Regards,
> >>Blair
> >>
> >>
> >
> >if test ! -z "$a"; then
> > echo not empty
> >fi
> >
> >That should work everywhere.
> >
> >
>
> But then the test doesn't work the way you want it to. Even if $a is "
> ", then the code in the if then fi should not be run. So using echo
> handles this case. Another way could be to use case, but then it
> doesn't look as clean in the code.
Ahh, yes. Sure its portable, but " " shouldnt be valid. I didnt think of that.
But in general putting quotes around variables is a safe way to avoid problems
with blank variables in test conditions.
Adam
More information about the Orca-users
mailing list