Open jkirk opened 1 year ago
The wiki is open to edits if you think it is important to extend the page. I am not sure really.
And I am not actually sure that you (or I?) have parsed the manual text about the variable MAPFILE correct. As far as Ican tell the the default variable used for storage by the mapfile
command if no target variable is specified is MAPFILE
.
A UPPERCASE variable named MAPFILE is not treated as an array just because of the name (your second example is a bit unclear because of the name change in this regard).
Hints on using the mapfile
command are present in SC2046, SC2206 and SC2207.
Thx @brother for your quick reply!
I somehow was not aware that this Wiki is open for everyone (funny how the visual impression can mislead one (or me(!): official wiki page vs Github Wiki apge).
But I am by no means (or at least I wouldn't call myself that way) an expert in bash programming (that's why I use shellcheck in the first place 😉 - and I also haven't heard of the mapfile
builtin before), so I do not really feel confident in editing the Wiki all by myself (there are no PRs which could be reviewed). So I need some advice and hope I can ask for help here.
About the MAPFILE
variable: Quoting bash-builtins(7):
mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array] [...] Read lines from the standard input into the indexed array variable array, or from file descriptor fd if the -u option is supplied. The variable MAPFILE is the default array.
And yes, I read it the same way. If no array (aka target variable) is given, the array variable will be called MAPFILE
.
That said, I would also say - as you already said -, an uppercase variable named MAPFILE
should not be treated as an array, just because of the name.
I was very confused about why shellcheck issued a SC2178-warning because I "accidentally" named my variable MAPFILE
.
So if an uppercase variable name MAPFILE
is nothing special, I'd call this a bug. If yes, I'd change the title.
For bugs
shellcheck --version
or "online"): onlineFor new checks and feature suggestions
Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
Look at this:
I am not sure, if a
MAPFILE
variable itself is a problem when not using the bash builtinmapfile
, but please let the user know, that there IS such a builtin and variable and/or that this variable name is reserved. The SC2178 wiki page (currently) does not mention MAPFILE.Thank you very much for
shellcheck
! 😄