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 06:15:16 -0500

This involves printing something to the screen. Is there something along
the line of [[ that doesn’t print to screen? Thanks.

On Thu, Mar 12, 2020 at 10:07 PM David <address@hidden> wrote:

> On Fri, 13 Mar 2020 at 13:59, Peng Yu <address@hidden> wrote:
>
> > What is the best way
> > to test whether a viable is declared?
>
> Here's one way:
>
> $ echo "$BASH_VERSION"
> 4.4.12(1)-release
> $ unset v
> $ declare -p v ; echo $?
> bash: declare: v: not found
> 1
> $ declare v
> $ declare -p v ; echo $?
> declare -- v
> 0
> $
>
> --
Regards,
Peng


reply via email to

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