bug-bash
[Top][All Lists]
Advanced

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

Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#le


From: L. A. Walsh
Subject: Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}
Date: Fri, 21 Oct 2016 21:19:08 -0700
User-agent: Thunderbird

Eduardo Bustamante wrote:
what's wrong with?:
echo address@hidden
It will return:
- With array=(1 2 3) -> 3
- With array=() -> 0
- With unset array -> 0
- With declare -a array -> 0

Seems to do what you're looking for.
----
Not when "-u" is set, which I often have on to help catch misspellings.

set -u
echo address@hidden
bash: array: unbound variable

Compare to:

if [[ ${yesno:-""} == yes ]]; then ... fi

# basically wanting 1 test for members, else return 0

if [[ address@hidden:-"undef"} != undef ]] && ((address@hidden))

tnx,
-l





reply via email to

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