Let's say I have a shell script test.sh, which should drive away a certain amount of values. I would like to be able to pass these values through an environment variable with the glob extension:
$ ls
1.js 2.js test.sh*
$ FOO="*.js" bash ./test.sh
1.js 2.js
Easy talk! Just write
#!/bin/bash
echo $FOO
and indeed it works. But it does not pass ShellCheck , which calls us to use implicit globbing / extension ( SC2086 ). (And this is true: in the source code, the echo line was cp $FOO $BARwhere we really did not want to expand $BAR, this error detects errors.)
So, in an effort to make this more explicit, I was hoping that perhaps the following would work:
#!/bin/bash
array=( $FOO )
echo "${array[@]}"
: SC2206.
, , ShellCheck ? ( - www.shellcheck.net, .) ? , ShellCheck ...