diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-10-10 20:06:51 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-10-10 20:06:51 +0300 |
commit | a7b8cb5bd8c17b174316e8bc8dc649612c478da7 (patch) | |
tree | 933c1be2ad0c15a9cc3c63aa25a5ecf6361ce00d /bash.md | |
parent | bash.md: code style (diff) | |
download | notes-a7b8cb5bd8c17b174316e8bc8dc649612c478da7.tar.gz notes-a7b8cb5bd8c17b174316e8bc8dc649612c478da7.zip |
bash.md: arrays & `unset`
Diffstat (limited to 'bash.md')
-rw-r--r-- | bash.md | 30 |
1 files changed, 24 insertions, 6 deletions
@@ -1,12 +1,30 @@ GNU `bash` ========== -1. (Associative) arrays - * Yes: +(Associative) arrays +-------------------- - func ${arr[@]+"${arr[@]}"} +### Expansion - * No: +Yes: - func "${arr[@]}" # doesn't work with `nounset` - func "${arr[@]+"${arr[@]}"}" # doesn't work with ('') + func ${arr[@]+"${arr[@]}"} + +No: + + func "${arr[@]}" # doesn't work with `nounset` + func "${arr[@]+"${arr[@]}"}" # doesn't work with ('') + +### `unset` + +Yes: + + unset -v 'arr[$i]' + +No: + + unset -v arr[x] # globbing + unset -v arr[$i] # the same problem + quoting + unset -v 'arr["x"]' # doesn't work for some reason + unset -v 'arr["]"]' # the same as above; just to highlight the problem with funny characters in array indices + # insightful discussion: https://lists.gnu.org/archive/html/help-bash/2016-09/msg00020.html |