Open itaranto opened 2 years ago
Double quotes are need in some shells. From example, this happens in Ubuntu 20.04 LTS, which ships with dash 0.5.10.2:
$ dash -c 'v="hello world"; export w=$v; echo "$w"'
hello
$ dash -c 'v="hello world"; export w="$v"; echo "$w"'
hello world
This was fixed only in dash 0.5.11: https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=cbb71a836874d176
Relevant POSIX bug: https://www.austingroupbugs.net/view.php?id=351
Yes, makes sense. I didn't realize because I always use up-to-date versions.
Since the dash bug was fixed in 2018, and also the POSIX bug seems fixed too (correct me if I'm wrong), maybe this warning can be removed once all "mayor" distros start switching to newer dash versions.
Also, bash doesn't seem to have this issue.
And what about the local
statement?
And what about the
local
statement?
local
is affected too:
$ dash -c 'v="hello world"; f() { local w=$v; echo "$w"; }; f'
hello
$ dash -c 'v="hello world"; f() { local w="$v"; echo "$w"; }; f'
hello world
For bugs
shellcheck --version
or "online"): 0.8.0Here's a snippet or screenshot that shows the problem:
This shouldn't be a problem, it should expand the variable in the same way that
FOO=$BAR
does, i.e. quotes are not required here.Here's another one:
I know that in POSIX
local
is not defined, but since almost every POSIX shell supports it, I make an exception.However, the last example works fine on Bash:
Here's what shellcheck currently says:
SC2086 (info): Double quote to prevent globbing and word splitting.
Here's what I wanted or expected to see:
Nothing