help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Awkward behavior of empty arrays


From: Chris F.A. Johnson
Subject: Re: [Help-bash] Awkward behavior of empty arrays
Date: Thu, 31 Aug 2017 15:12:15 -0400 (EDT)
User-agent: Alpine 2.10 (DEB 1266 2009-07-14)

On Thu, 31 Aug 2017, Cristian Zoicas wrote:


Hello all

I want to create arrays and use them (easily). I am especially
interested in empty arrays and I felt very uncomfortable with them
since I found some  counterintuitive or undocumented behaviors.  I
provide some examples below.

Example 1:

   1 set -u;
   2 unset A;
   3 declare -a A=;

You have set A[0] to the empty string.

If you don't want to set A[0], use:

declare -a A ## No =


--
Chris F.A. Johnson, <http://cfajohnson.com>



reply via email to

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