Re: Test existence of shell variable, bash, csh

2001-05-06 Thread Dimitri Maziuk
On Sat, May 05, 2001 at 02:34:47PM -0700, Karsten M. Self wrote: > This came up on another list. The problem involves testing existence of > a Unix shell variable from another program with limited system > interaction features. ... >$?MYVAR > > ...which allows testing of presence of a variabl

Re: Test existence of shell variable, bash, csh

2001-05-06 Thread Karsten M. Self
on Sun, May 06, 2001 at 01:54:26PM +0300, Tommi Komulainen ([EMAIL PROTECTED]) 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 ([EMAIL > > PROTECTED]) wrote: > > > > > > if test "${LANG+set}" = set; then LAN

Re: Test existence of shell variable, bash, csh

2001-05-06 Thread Richard Cobbe
Lo, on Saturday, May 5, Ethan Benson did write: > On Sat, May 05, 2001 at 02:34:47PM -0700, Karsten M. Self wrote: > > This came up on another list. The problem involves testing existence of > > a Unix shell variable from another program with limited system > > interaction features. > > > > I us

Re: Test existence of shell variable, bash, csh

2001-05-06 Thread Tommi Komulainen
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 ([EMAIL > PROTECTED]) 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

Re: Test existence of shell variable, bash, csh

2001-05-05 Thread Karsten M. Self
on Sun, May 06, 2001 at 02:22:40AM +0300, Tommi Komulainen ([EMAIL PROTECTED]) wrote: > On Sat, May 05, 2001 at 02:34:47PM -0700, Karsten M. Self wrote: > > > > In contrast, csh and derivatives have: > > > >$?MYVAR > > > > ...which allows testing of presence of a variable. > > > > ...but I

Re: Test existence of shell variable, bash, csh

2001-05-05 Thread Alan Shutko
"Karsten M. Self" writes: > ...but I'm not aware of a similar bash/korn/bourne feature. Anyone? if [ "${VAR:-invalid" = "invalid" ] ; echo "Unset" fi ? -- Alan Shutko <[EMAIL PROTECTED]> - In a variety of flavors! Happiness is the greatest good.

Re: Test existence of shell variable, bash, csh

2001-05-05 Thread Ethan Benson
On Sat, May 05, 2001 at 02:34:47PM -0700, Karsten M. Self wrote: > This came up on another list. The problem involves testing existence of > a Unix shell variable from another program with limited system > interaction features. > > I usually write this in bash as: > > if [ x${MYVAR} = x ]; t

Re: Test existence of shell variable, bash, csh

2001-05-05 Thread Ethan Benson
On Sat, May 05, 2001 at 04:35:02PM -0700, Karsten M. Self wrote: > > > > Some bourne shells don't like testing variables that don't exist yet. > > That's precisely what we're trying to test. where you run in to trouble really is when you don't quote the variable, for example: if [ $FOO = bar ]

Re: Test existence of shell variable, bash, csh

2001-05-05 Thread Karsten M. Self
on Sat, May 05, 2001 at 04:08:26PM -0700, Eric G. Miller (egm2@jps.net) wrote: > On Sat, May 05, 2001 at 02:34:47PM -0700, Karsten M. Self wrote: > > This came up on another list. The problem involves testing existence of > > a Unix shell variable from another program with limited system > > inter

Re: Test existence of shell variable, bash, csh

2001-05-05 Thread Tommi Komulainen
On Sat, May 05, 2001 at 02:34:47PM -0700, Karsten M. Self wrote: > > In contrast, csh and derivatives have: > >$?MYVAR > > ...which allows testing of presence of a variable. > > ...but I'm not aware of a similar bash/korn/bourne feature. Anyone? Coming soon to ./configure scripts near you

Re: Test existence of shell variable, bash, csh

2001-05-05 Thread Eric G. Miller
On Sat, May 05, 2001 at 02:34:47PM -0700, Karsten M. Self wrote: > This came up on another list. The problem involves testing existence of > a Unix shell variable from another program with limited system > interaction features. > > I usually write this in bash as: > > if [ x${MYVAR} = x ]; t

Re: Test existence of shell variable, bash, csh

2001-05-05 Thread MaD dUCK
also sprach Karsten M. Self (on Sat, 05 May 2001 02:34:47PM -0700): > ...but I'm not aware of a similar bash/korn/bourne feature. Anyone? if [ "$variable" ]; then ... martin; (greetings from the heart of the sun.) \ echo mailto: !#^."<*>"|tr "<*> mailto:"; [EMAIL PROTECTED] --

Test existence of shell variable, bash, csh

2001-05-05 Thread Karsten M. Self
This came up on another list. The problem involves testing existence of a Unix shell variable from another program with limited system interaction features. I usually write this in bash as: if [ x${MYVAR} = x ]; then echo 'MYVAR doesn't exist (or isn't set)' else echo "MYVAR