[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
4.4 change in behavior from 4.3: how to catch unset when using ${#length
From: |
L. A. Walsh |
Subject: |
4.4 change in behavior from 4.3: how to catch unset when using ${#length} |
Date: |
Fri, 21 Oct 2016 14:41:12 -0700 |
User-agent: |
Thunderbird |
On 4.3 and earlier, at least on arrays, one could have
the illusion of this working w/o complaint -- and returning
0 when the array was 0-len or unset, or the array length,
otherwise:
echo ${#array[@]:-0}
But I note it only seemed to work in arrays, and in 4.4 gets a
syntax error:
echo ${#array[@]:-0}
bash: ${#array[@]:-0}: bad substitution
Is there any reason why such a syntax wouldn't be workable --
including adding:
echo ${#wordlen:-0} to allow catching an undefined word?
or is there some other, inline way to do this?
-linda
- 4.4 change in behavior from 4.3: how to catch unset when using ${#length},
L. A. Walsh <=
- Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}, Eduardo Bustamante, 2016/10/22
- Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}, Chet Ramey, 2016/10/24
- Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}, L. A. Walsh, 2016/10/24
- Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}, Chet Ramey, 2016/10/28
- Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}, L. A. Walsh, 2016/10/28
- Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}, Chet Ramey, 2016/10/28
- Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}, L. A. Walsh, 2016/10/29
- Re: 4.4 change in behavior from 4.3: how to catch unset when using ${#length}, Chet Ramey, 2016/10/29