bug-bash
[Top][All Lists]
Advanced

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

Expanding an undefined array


From: Bernd Eggink
Subject: Expanding an undefined array
Date: Wed, 24 Sep 2008 23:33:19 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080707)

Is the following difference intentional, a bug, or do I miss something?

  unset a
  set -- "${a[@]}"
  echo $#

Output: 0

  typeset a
  set -- "${a[@]}"
  echo $#

Output: 1

The man page says, "If the word is double-quoted, ... ${name[@]} expands each element of name to a separate word. When there are no array members, ${name[@]} expands to nothing." It doesn't mention a difference between an empty and an unset variable in this context. As a quoted 'nothing' normally counts 1 word, the 'nothing' in the first example appears to be some kind of 'super-nothing'.

Regards,
Bernd

--
Bernd Eggink
monoped@sudrala.de
http://sudrala.de




reply via email to

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