robbat2 said on #-dev to file a bug about this. * QA Notice: shell script appears to use non-POSIX feature(s): * possible bashism in /etc/init.d/bootmisc line 30 ([^] should be [!]): * if ! rm -rf -- [^ajlq\.]* 2>/dev/null ; then * possible bashism in /etc/init.d/bootmisc line 137 (type): * if type fuser >/dev/null 2>&1; then * QA Notice: shell script appears to use non-POSIX feature(s): * possible bashism in /etc/init.d/hostname line 13 ($HOST(TYPE|NAME)): * hostname=${hostname-${HOSTNAME-localhost}} * QA Notice: shell script appears to use non-POSIX feature(s): * possible bashism in /etc/init.d/local line 22 (type): * if type local_start >/dev/null 2>&1; then * possible bashism in /etc/init.d/local line 42 (type): * if type local_start >/dev/null 2>&1; then
(In reply to comment #0) > * QA Notice: shell script appears to use non-POSIX feature(s): > * possible bashism in /etc/init.d/bootmisc line 30 ([^] should be [!]): > * if ! rm -rf -- [^ajlq\.]* 2>/dev/null ; then It looks like checkbashisms is seeing the wildcard expression as the condision here? > * possible bashism in /etc/init.d/bootmisc line 137 (type): > * if type fuser >/dev/null 2>&1; then What's wrong with this? I thought type was posix? > * QA Notice: shell script appears to use non-POSIX feature(s): > * possible bashism in /etc/init.d/hostname line 13 ($HOST(TYPE|NAME)): > * hostname=${hostname-${HOSTNAME-localhost}} This also seems to work? I tried something similar from the command line in dash? > * QA Notice: shell script appears to use non-POSIX feature(s): > * possible bashism in /etc/init.d/local line 22 (type): > * if type local_start >/dev/null 2>&1; then > > * possible bashism in /etc/init.d/local line 42 (type): > * if type local_start >/dev/null 2>&1; then These are more complaints about type?
(In reply to comment #1) > (In reply to comment #0) > > * QA Notice: shell script appears to use non-POSIX feature(s): > > * possible bashism in /etc/init.d/bootmisc line 30 ([^] should be [!]): > > * if ! rm -rf -- [^ajlq\.]* 2>/dev/null ; then > > It looks like checkbashisms is seeing the wildcard expression as the > condision here? > > > * possible bashism in /etc/init.d/bootmisc line 137 (type): > > * if type fuser >/dev/null 2>&1; then > > What's wrong with this? I thought type was posix? > It is -- see http://pubs.opengroup.org/onlinepubs/009695399/utilities/type.html
@robbat2: It appears that these are false positives. If you disagree, please re-assign this to OpenRC and we can go from there. Thanks, William
I have posted to devscripts-devel@debian asking what they think about this issue.
Apparently 'type' is an XSI extension, rather than pure POSIX. An example of a shell that does not support this is app-shells/posh.
(In reply to comment #5) > Apparently 'type' is an XSI extension, rather than pure POSIX. > > An example of a shell that does not support this is app-shells/posh. Maybe you could use 'command -v' rather than 'type'? Although it's not exactly the same thing...
I have fixed many bashisms. The following are left: 1. "type" function usage. This is an POSIX XSI extension. I'm not convinced we should remove it. 2. I have marked 2 false positives where we use bashisms with fallbacks. 3. checkbashisms gets quote & heredoc handling wrong in some complex cases, leading to either parse errors: error: init.d/net.lo.in: Unterminated quoted string found, EOF reached. Wanted: <"> error: net/ip6rd.sh: Unterminated heredoc found, EOF reached. Wanted: <24> error: net/iwconfig.sh.Linux.in: Unterminated quoted string found, EOF reached. Wanted: <'> error: net/pppd.sh: Unterminated quoted string found, EOF reached. Wanted: <"> or severe false positives: possible bashism in net/iwconfig.sh.Linux.in line 81 ([^] should be [!]): LC_ALL=C iwconfig "${IFACE}" | \ sed -n -e 's/^'"$1"' *\([^ ]* [^ ]*\).*/\1/p' Do NOT change that ^ to !, they are in the sed expression, not a pathname pattern. 4. These are two more actual bashisms we should consider carefully: possible bashism in sh/functions.sh.in line 65 (alias): alias -g '${1+"$@"}'='"$@"' possible bashism in sh/runscript.sh.in line 205 (ulimit): [ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT} alias does not take options in POSIX, and ulimit is for file size only.
$ checkbashisms $(find init.d*/* net/* sh/* scripts/* ! -name Makefile) 2>&1 |fgrep -f exclude -v Where 'exclude' is a file containing: ==== interpreter line does not appear to be (type) if type && type ====
@robbat2: I am moving this back to openrc since you are on the alias.
(In reply to comment #5) "command" is not an alternative to "type" when it comes to functions the `alias -g` isn't an issue. if you read the code, it's only executed for zsh.
(In reply to SpanKY from comment #10) > (In reply to comment #5) > > "command" is not an alternative to "type" when it comes to functions This is not the case. The meaningful differences between type and command -v for resolving functions are as follows. Firstly, type was (and still is) an XSI extension. Secondly, command -v used to require support for the User Portability Utilities option but this constraint was lifted in Issue 7. Thirdly, the output of type is unspecified. Not that bootmisc was doing so, but it should never be parsed in portable code. Anyway, I see that bootmisc no longer uses type. As there hasn't been any further discussion for some 12 years, I think that this bug should be closed.
Closing, per my previous comment. I briefly checked bootmisc for POSIX violations and found that only the use of "local" counts as one at this point.