can't ignore SC2024 with inline directive `# shellcheck disable=SC2024`
#### For bugs with existing features
- Rule Id SC2024
- "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:
```bash
#!/bin/bash
errorlog=/tmp/error.log
# shellcheck disable=SC2024
sudo apt update; sudo apt install -y google-chrome-stable >> "$errorlog"
echo "$errorlog"
exit
```
#### Here's what shellcheck currently says:
```
$ shellcheck myscript
[Line 4:](javascript:setPosition(4, 59))
sudo apt update; sudo apt install -y google-chrome-stable >> "$errorlog"
^-- [SC2024](https://www.shellcheck.net/wiki/SC2024) (warning): sudo doesn't affect redirects. Use .. | sudo tee -a file
$
```
#### Here's what I wanted or expected to see:
```
$ shellcheck myscript
No issues detected!
$
```
#### Additional:
- Tried removing the indentation, still shows the warning.
- Tried stripping the code down to bare minimum (functional line between shbang and shellcheck directive: i.e., declare var, echo var after, exit.)
- Tried adding it to the script-wide directive (i.e., under the shbang) and it removed the warning.
- The wiki page specifically says this can be ignored:
> Exceptions
> If you want to run a command as root but redirect as the normal user, you can [ignore](https://www.shellcheck.net/wiki/ignore) this message.
4 条评论