shellcheck
shellcheck copied to clipboard
SC2140 triggers for slash on parameter expansion replacement
Shellcheck complains that / is not quoted, but it's part of the expansion syntax, it's not something to be quoted.
% shellcheck --version
ShellCheck - shell script analysis tool
version: 0.4.1
license: GNU General Public License, version 3
website: http://www.shellcheck.net
% shellcheck -s bash /dev/stdin << 'EOF'
>>> : "${PHOTO_DIR/"'"/"'\\''"}"
>>> EOF
In /dev/stdin line 1:
: "${PHOTO_DIR/"'"/"'\\''"}"
^-- SC2140: Word is on the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?
I think the issue here is that the quoted parts in the expansion are being parsed as T_NormalWord, and therefore match the first pattern in checkInexplicablyUnquoted. Ideally, a slash in a parameter expansion would be treated as a special character - I'm currently unsure what Token constructor to use, but I hope to have this working on my fork sometime in the next few days.
As a side note, I'm thinking the error message is meant to say "Word is of the form" (rather than "on").