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: Eli Schwartz
Subject: Re: How to test if a variable is declared?
Date: Fri, 13 Mar 2020 09:11:00 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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