Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Thanks. ${var+set} treats var as var[0]. Does $(parameter+word expect parameter to be a nonarray variable? If not, how can I specify parameter to represent an array? Commented Jul 24, 2017 at 19:39
  • In 4.4, when run unset var and declare -i var, then run declare -p var. Does it output error such as bash: declare: var: not found or declare -i var? I would like to see if it treats array differently from other types. I have 4.3 only. Commented Jul 24, 2017 at 23:08
  • That is not the correct way to test an array: ${var[@]+set} is (:+ fails on ksh93). What you used only test index 0. Commented Jul 24, 2017 at 23:38
  • In bash: typeset -p var would return an error only in 4.3, It was correct before and became correct with 4.4 again. Commented Jul 24, 2017 at 23:49
  • @Tim, it outputs declare -i var. Commented Jul 25, 2017 at 7:05