[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to test if a variable is declared?
From: |
Peng Yu |
Subject: |
How to test if a variable is declared? |
Date: |
Thu, 12 Mar 2020 21:58:38 -0500 |
Hi,
-v only test if a variable has a nonempty value. What is the best way
to test whether a viable is declared? (In the following example, it
should return 0, even the value of x is an empty string.) Thanks.
$ declare x; [[ -v x ]]; echo $?;
1
-v varname
True if the shell variable varname is set (has been assigned a
value).
--
Regards,
Peng
- How to test if a variable is declared?,
Peng Yu <=
- Re: How to test if a variable is declared?, David, 2020/03/12
- Re: How to test if a variable is declared?, Peng Yu, 2020/03/13
- Re: How to test if a variable is declared?, Andreas Kusalananda Kähäri, 2020/03/13
- Re: How to test if a variable is declared?, Peng Yu, 2020/03/13
- Re: How to test if a variable is declared?, Eli Schwartz, 2020/03/13
- Re: How to test if a variable is declared?, Peng Yu, 2020/03/13
- Re: How to test if a variable is declared?, Pier Paolo Grassi, 2020/03/13
- Re: How to test if a variable is declared?, Peng Yu, 2020/03/13
- Message not available
- Re: How to test if a variable is declared?, Peng Yu, 2020/03/13
- Re: How to test if a variable is declared?, David, 2020/03/13