[CLUE-Tech] bash question
Keith Hellman
kehellman at yahoo.com
Fri Jun 14 12:13:53 MDT 2002
Hmmpha!
typeset -p VAR 2>&1 >/dev/null ; test $?
--- Keith Hellman <kehellman at yahoo.com> wrote:
>
> Does anyone know how to determine if bash environmental variable exists?
>
> Note, I know of ( test -z "${VAR}" ); but this doesn't tell me if the
> var
> EXISTS, it just tells me if it expands to a non-empty string.
>
> I could do ( set |grep VAR >/dev/null ); test $?
> but this requires an invokation of grep, which seems wasteful.
>
> readonly does not return an error value when VAR does not exist.
>
> I could write an external program to inspect the environment, but this
> would only detect exported vars; it also has the same downside of
> grep...
>
> It seems strange that this simply query is not available - I must be
> missing something in the docs.
>
> I'm twiddling with the set builtin now - I think I can coerce it into a
> valid test...
>
> The upside is that I have to scan the docs well, so I keep finding bash
> features I always wished I had :^)
>
> TIA
>
>
> =====
> Keith E. Hellman
> kehellman at yahoo.com
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> _______________________________________________
> CLUE-Tech mailing list
> CLUE-Tech at clue.denver.co.us
> http://clue.denver.co.us/mailman/listinfo/clue-tech
=====
Keith E. Hellman
kehellman at yahoo.com
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
More information about the clue-tech
mailing list