Open
Description
The documentation states https://www.shellcheck.net/wiki/SC2016:
ShellCheck tries to increase the signal-to-noise ratio of this warning by ignoring certain well known commands that frequently expect literal dollar signs, such as sh and perl.
It would be nice if it tried to detect at least some common grep patterns.
A simple test case would be checking if there's a literal $123
.
#!/bin/sh
head -n 1 /dev/urandom | grep -E '\$123'
-> SC2016
There are workarounds, but they are quite ugly. Triple backslash within double quotes gets very confusing.
#!/bin/sh
head -n 1 /dev/urandom | grep -E '\$[1]23'
head -n 1 /dev/urandom | grep -E "\\\$123"
This passes!
Other common error case goes like this:
#!/bin/sh
head -n 1 /dev/urandom | grep -E '\$(ab|cd)'
-> SC2016
Metadata
Metadata
Assignees
Labels
No labels