shellcheck
shellcheck copied to clipboard
SC2001 should not be recommended when shebang is /bin/ksh
For bugs
- SC2001:
- My shellcheck version (
shellcheck --version
or "online"): 0.9.0 - [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/ksh
x="foo"
foo=$(echo "$x" | sed -e 's,foo,bar,')
echo "$foo"
Here's what shellcheck currently says:
^-- SC2001 (style): See if you can use ${variable//search/replace} instead.
Here's what I wanted or expected to see:
Shellcheck should not be suggesting this as this is a bash/zsh feature and not present in ksh
in ksh using ${a//b/c} or ${a//b/c} will produce 'bad substitution' when used in the way suggested by shellcheck.