shellcheck
shellcheck copied to clipboard
SC2016 incompatibility with `sed` command
For bugs with existing features
- SC2016
- online
- [x] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
- [x] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
#!/bin/bash
sed 's/[][\.|$(){}?+*^]/\\&/g'
Here's what shellcheck currently says:
In btest.sh line 2:
sed 's/[][\.|$(){}?+*^]/\\&/g'
^------------------------^ SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
Here's what I wanted or expected to see:
nothing.
Rationale
sed command can contain as many RegEx signs, as possible. The ShellCheck should ignore internal content of this command.