Open urxvtcd opened 1 year ago
I know like basics of Haskell, so I might want to help here. This would probably require creating a list of commands specified by POSIX and checking if they are run with long options. Didn't look into codebase, but that just might be doable. Any thoughts before I try?
Aren't you mixing concepts here?
getopts will not work with long options. wc on the other hand might be a command that can recognize long options (my wc
does for instance).
I don't think I am. wc
as specified by POSIX does not accept long options1, and the fact that it does on someone's system and not on some other one can introduce portability issues without them knowing, which is what I'd like shellcheck to report here.
but wc is not a builtin, it's still external. there are some commands supported by shellcheck and so on.
I'm afraid I don't understand. Why does it matter whether wc is a builtin or not? I guess it's a useful check to have if one wants to check if their script is portable, and we can't count on wc supporting long options. Am I missing something?
I suspect @brother's comment was related to the fact that wc
is an external program (i.e., not a shell builtin).
That said, (not to speak for them) they may not realize that wc
is also part of POSIX, and in POSIX, wc
DOES NOT require long options:
https://pubs.opengroup.org/onlinepubs/000095399/utilities/wc.html
So, yeah, valid bug.
@austin987 exactly that and shellcheck does have some "known" commands where some behaviour is known and supported. That said, shellcheck is not a posix support tool - not even with sh as shebang. I have no opinion regarding adding wc to a list of commands not allowing long options when in sh mode.
For new checks and feature suggestions
Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Nothing
Here's what I wanted or expected to see:
In POSIX sh, long options are not defined.