From 430e95967e8968554a888cce365830bce5d46ee6 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 11 Oct 2016 01:28:20 +0300 Subject: bash.md: update --- bash.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bash.md b/bash.md index ca3c722..1ca3d13 100644 --- a/bash.md +++ b/bash.md @@ -6,25 +6,27 @@ GNU `bash` ### Expansion -Yes: +#### Do func ${arr[@]+"${arr[@]}"} -No: +#### Don't - func "${arr[@]}" # doesn't work with `nounset` - func "${arr[@]+"${arr[@]}"}" # doesn't work with ('') + func "${arr[@]}" # Doesn't work with `nounset`. + func "${arr[@]+"${arr[@]}"}" # Doesn't work properly with `declare -a arr=('')`. ### `unset` -Yes: +#### Do unset -v 'arr[$i]' -No: +#### Don't - 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 + unset -v arr[x] # May break due to globbing. + unset -v arr[$i] # The same as above + possibly a pair of quotes is + # missing. + unset -v 'arr["x"]' # Doesn't work for some reason. + unset -v 'arr["]"]' # The same as above; just highlighting the problem + # with funny characters in array indices. + # An insightful discussion: https://lists.gnu.org/archive/html/help-bash/2016-09/msg00020.html. -- cgit v1.2.3