|
From: | L A Walsh |
Subject: | Re: What is correct syntax to check for empty array? behavior diffs between 4.3 and 4.4 |
Date: | Thu, 26 Jan 2017 13:23:56 -0800 |
User-agent: | Thunderbird |
Greg Wooledge wrote:
On Thu, Jan 26, 2017 at 01:11:25PM -0800, L A Walsh wrote:Subject: Re: What is correct syntax to check for empty array?The number of elements is 0 if the array is empty. So you would test whether ${#array[@]} is 0.set -u # now add an undefined checkNow you've changed the question. You're no longer asking whether an array is empty. You're asking whether some legacy crap from 197x will make your shell script abort. Answer: who the hell cares. Stop doing it.
--- get a life. I'll stop doing it when it is removed. Otherwise, I'll see your answer as being "I don't know, so let's call the user's choices 'crap'" -- i.e. not at all useful. I was really tempted to add: (opinions on use of "-u" are not being solicited) to my original note, but I didn't want to be presume someone would be sounhelpful...
If you don't think it is working correctly, SUBMIT A BUG. Otherwise, stop telling people to not use bash's *documented* features.
[Prev in Thread] | Current Thread | [Next in Thread] |