-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Busybox sh and glob matching #2998
Comments
Here is a more advanced example that shows some issues when using globmatching where the glob can be expanded accidentally: Here's a snippet or screenshot that shows the problem:#!/bin/busybox sh
testglob() {
local var1="barfoobar"
local var2="foobar"
local var3="barfoo"
local var4="bar"
[[ ${var1} == *foo* ]] && echo "(unquoted pattern) var1 true" || echo "(unquoted pattern) var1 false"
[[ ${var2} == *foo* ]] && echo "(unquoted pattern) var2 true" || echo "(unquoted pattern) var2 false"
[[ ${var3} == *foo* ]] && echo "(unquoted pattern) var3 true" || echo "(unquoted pattern) var3 false"
[[ ${var4} == *foo* ]] && echo "(unquoted pattern) var4 true" || echo "(unquoted pattern) var4 false"
[[ ${var1} == "*foo*" ]] && echo "(quoted pattern) var1 true" || echo "(quoted pattern) var1 false"
[[ ${var2} == "*foo*" ]] && echo "(quoted pattern) var2 true" || echo "(quoted pattern) var2 false"
[[ ${var3} == "*foo*" ]] && echo "(quoted pattern) var3 true" || echo "(quoted pattern) var3 false"
[[ ${var4} == "*foo*" ]] && echo "(quoted pattern) var4 true" || echo "(quoted pattern) var4 false"
}
rm -f barfoobar xfoox && echo "Neither file barfoobar nor xfoox exist"
testglob
echo
touch barfoobar && echo "File barfoobar exists"
testglob
echo
touch xfoox && echo "File barfoobar and file xfoox exists"
testglob
echo That will output:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:In the above example, the error seems valid, as it requires quoting to work properly. But it should very likely be reworded. |
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For bugs
shellcheck --version
or "online"): online / ac8fb00Here's a snippet or screenshot that shows the problem:
Basic glob matching does seem to work with
BusyBox v1.35.0
:returns
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
No error, but maybe some warning instead (see example below).
The text was updated successfully, but these errors were encountered: