shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

SC2016 incompatibility with `sed` command

Open IvanGrigorik opened this issue 4 months ago • 0 comments

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.

IvanGrigorik avatar Sep 17 '25 20:09 IvanGrigorik