-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SC3021 warning is bogus #2520
Comments
Note that shellcheck's warning disappears when I write |
You're right. ShellCheck confused your perfectly portable Thanks! |
Thanks, the issue is fixed now. And I think ShellCheck handles the bash extensions |
For bugs
shellcheck --version
or 'online'): onlineHere's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
Expected output: No warning.
Rationale:
sh
is at https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/sh.html , and the description of the shell language is at https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html . Here, section 2.7 describes redirections, and section 2.7.6 describes the >& operator.The description says "If word evaluates to one or more digits, the file descriptor denoted by n, or standard input if n is not specified, shall be made to be a copy of the file descriptor denoted by word".
$ofd
is a valid word in this place, because: When you look at the grammar in section 2.10.2, the token >&, represented byGREATAND
is followed byfilename
, andfilename
has the comment "Apply rule 2", and rule 2 says "The expansions specified in [Redirection] shall occur."prints 'hi', with no error or warning. Tested with
In other words, there is no actual portability problem with this code.
The text was updated successfully, but these errors were encountered: