Updated SC3021 (markdown)

Vidar Holen
2022-07-22 16:58:44 -07:00
parent 673dc51de2
commit ee665b3ce6

@@ -1,2 +1,9 @@
## In POSIX sh, `>&` is undefined.
See similar warning [[SC3020]]
This warning was retracted after 0.8.0.
There are two forms of this operator: `>& fd`, and `>& filename`. The former is POSIX, and copies stdout to the given file descriptor or fails if it's not an integer. The latter is a bash specific extension meaning `> filename 2>&1`. Bash will interpret `>& $var` as one or the other depending on whether the value is an integer.
ShellCheck 0.8.0 and below was unable to differentiate and unintentionally treated both as `>& filename`, causing an invalid warning when the value was an integer.
If your script uses `>&` with an integer to copy a file descriptor, please ignore this warning. If it uses it to write both stdout and stderr to a filename, like `&>`, rewrite it explicitly to `> file 2>&1`.