[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
`declare -a NAME` followed by `declare -p NAME`
From: |
Ivan Shapovalov |
Subject: |
`declare -a NAME` followed by `declare -p NAME` |
Date: |
Mon, 05 Jan 2015 05:31:14 +0300 |
User-agent: |
KMail/4.14.3 (Linux/3.18.0-pf0-intelfx-00221-ge2e81b9; KDE/4.14.3; x86_64; ; ) |
If an empty array is declared using `declare -a NAME` and then immediately
`declare -p NAME` is invoked, it says there is no such variable. However,
if one assigns some values to the array, `declare -p` works then as expected.
That is: `declare -p NAME` does not work on an array which has been declared
but not yet assigned anything.
However, the array can be found in output of `declare -p` without NAME given.
Testcase:
----
$ declare -a __test
$ declare -p | grep __test
declare -- _="__test"
declare -a __test='()'
$ declare -p __test
bash: declare: __test: not found
$ __test=("")
$ declare -p __test
declare -a __test='([0]="")'
----
Bash version: 4.3.30(1)-release
Distro: Arch Linux
Thanks,
--
Ivan Shapovalov / intelfx /
signature.asc
Description: This is a digitally signed message part.
- `declare -a NAME` followed by `declare -p NAME`,
Ivan Shapovalov <=