help-bash
[Top][All Lists]
Advanced

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

Re: How to test if a variable is declared?


From: Peng Yu
Subject: Re: How to test if a variable is declared?
Date: Fri, 13 Mar 2020 08:15:21 -0500

I also said along the line of [[. I probably should make it more clear that
I just want to test if a variable is declared but not anything else.

On Fri, Mar 13, 2020 at 8:11 AM Eli Schwartz <address@hidden>
wrote:

> On 3/13/20 8:55 AM, Peng Yu wrote:
> > This still prints. It just got redirected to null. So when the variable
> > contains a long string, it will use extra CPU for a test that could be
> made
> > more light weight. So there is no way to just test if a variable is
> > declared in bash?
>
> Is "no, there isn't" an acceptable answer?
>
> The closest you will get is printing it out to null, and testing the
> return status of that print.
>
> P.S. If your initial response is "I don't want it to print to the
> screen", and then when someone shows you how to not print to the screen
> and you change your mind and say "I don't want it to print at all", it
> gets rather frustrating. Maybe it would be beneficial if you list your
> conditions from the start, rather than waiting for people to give you
> answers you don't like?
>
> --
> Eli Schwartz
> Arch Linux Bug Wrangler and Trusted User
>
> --
Regards,
Peng


reply via email to

[Prev in Thread] Current Thread [Next in Thread]