I use shellcheck to check over my bash shell scripts. Most of what it
generates is noise, but every so often, it produces something useful -
something that should be fixed/cleaned up.
I recently added some code to the script and ran shellcheck on it, and it
generated the output below:
--- Cut here ---
In myScript line 145:
[[ "$REPLY" =~ ^\^ ]] && REPLY="title not like '%${REPLY:1}%'"
^-- SC1001: This \^ will be a regular '^' in this context.
^-- SC2089: Quotes/backslashes will be treated literally. Use an array.
--- Cut here ---
The intent is to check to see if $REPLY starts with a ^ and if so, change
it to the indicated string (yes, I am building up a SQL query). In my
testing, I determined that the right syntax in a Bash =~ test, to check for
a leading ^, is ^\^. So, what is the SC1001 complaining about? Isn't that
the right syntax to use?
Second, I don't understand the second error at all. What does "Use an
array" mean?
Note that the script works fine. There's nothing really wrong with it at all.
--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/EternalFlame