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

Re: Test existence of shell variable, bash, csh



on Sun, May 06, 2001 at 01:54:26PM +0300, Tommi Komulainen (Tommi.Komulainen@iki.fi) wrote:
> On Sat, May 05, 2001 at 07:25:35PM -0700, Karsten M. Self wrote:
> > on Sun, May 06, 2001 at 02:22:40AM +0300, Tommi Komulainen (Tommi.Komulainen@iki.fi) wrote:
> > > 
> > > if test "${LANG+set}" = set; then LANG=C; export LANG; fi
> > 
> > Close, but not quite.  It's probably the nearest thing to a winner I've
> > seen posted though.  And you just edged out Alan's suggestion of an
> > equivalent but opposite test.
> 
> Umm, you wanted to test if a variable is set, the test does exactly that,
> not the opposite.
> 
> 
> > The possible problem"  "*null or* unset".  An existing, but null,
> > environment variable will be reported as unset.
> 
> hrmpf, I *know* I should've emphasized the following the first time:
> 
> > >        arithmetic  expansion.   When  not  performing   substring
> > >        expansion,  bash  tests  for  a parameter that is unset or
> > >        null; omitting the colon results in  a  test  only  for  a
>                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > >        parameter that is unset.
>            ^^^^^^^^^^^^^^^^^^^^^^^^

I've enrolled in a reading comprehension course.

-- 
Karsten M. Self <kmself@ix.netcom.com>    http://kmself.home.netcom.com/
 What part of "Gestalt" don't you understand?       There is no K5 cabal
  http://gestalt-system.sourceforge.net/         http://www.kuro5hin.org

Attachment: pgpWugNrCeyWF.pgp
Description: PGP signature


Reply to: