[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Expansions for array assignment not documented
From: |
E. Choroba |
Subject: |
Expansions for array assignment not documented |
Date: |
Fri, 17 Apr 2020 11:48:37 +0200 (CEST) |
User-agent: |
Alpine 2.21 (LSU 202 2017-01-01) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.4
-L/home/abuild/rpmbuild/BUILD/bash-4.4/../readline-7.0
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu'
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I. -I./include -I./lib -fmessage-length=0
-grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong
-funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g
-D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g -Wuninitialized -Wextra -Wno-switch-enum
-Wno-unused-variable -Wno-unused-parameter -Wno-parentheses -ftree-loop-linear
-pipe -DBNC382214=0 -DIMPORT_FUNCTIONS_DEF=0 -fprofile-use -fprofile-correction
uname output: Linux triangle 4.12.14-lp151.28.44-default #1 SMP Fri Mar 20
18:20:20 UTC 2020 (dbf1aea) x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux-gnu
Bash Version: 4.4
Patch Level: 23
Release Status: release
Description:
Expansions in an assignment are documented under "SIMPLE COMMAND EXPANSION":
> The text after the = in each variable assignment undergoes tilde
> expansion, parameter expansion, command substitution, arithmetic
> expansion, and quote removal before being assigned to the
> variable.
However, a compound assignment to an array is different: the
values also undergo pathname and brace expansions:
files=(*)
numbers=({1..10})
Originally discovered by Roland at
https://stackoverflow.com/q/61267714/1030675.
Repeat-By:
I've searched the whole "man bash" for "array" and haven't found
this documented. It's possible I've missed the documentation.
Fix:
The additional expansions should be documented either in the
paragraph quoted above, or in the "ARRAYS" section where compound
assignment is described.
Cheers,
Ch.
- Expansions for array assignment not documented,
E. Choroba <=