bug-bash
[Top][All Lists]
Advanced

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

Re: What is correct syntax to check for empty array? behavior diffs betw


From: Greg Wooledge
Subject: Re: What is correct syntax to check for empty array? behavior diffs between 4.3 and 4.4
Date: Thu, 26 Jan 2017 16:15:23 -0500
User-agent: Mutt/1.4.2.3i

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 check

Now 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.



reply via email to

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