[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unset FOO
From: |
Eric Blake |
Subject: |
Re: unset FOO |
Date: |
Tue, 14 Oct 2008 16:21:09 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Peter Seebach <seebs <at> seebs.net> writes:
> >> ${FOO+unset FOO}
> >>
> >No, it does NOT work in Solaris sh (tested on Solaris 8):
> >
> I think it needs to be in quotes, as with other {x+a b} expansions.
Quotes won't help; the shell then tries to evaluate the command 'unset FOO'
with no arguments, because there is no reason to do IFS splitting.
> I may
> have tested it in double quotes or something. Or I may just have been
> confused.
But this works, using an intermediate variable, so that IFS splitting still
occurs:
$ /bin/sh -c 'foo=a;tmp="unset foo";${foo+$tmp};echo ${foo+set}'; echo $?
0
$
But why waste the time going through a temporary variable, when you can use:
test ${foo+set} = set && unset foo
--
Eric Blake