Summary: | sys-apps/openrc: fix checkbashisms errors where possible | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Michael Palimaka (kensington) <kensington> |
Component: | Current packages | Assignee: | OpenRC Team <openrc> |
Status: | CONFIRMED --- | ||
Severity: | normal | CC: | alexander, pesa |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | http://thread.gmane.org/gmane.linux.debian.devel.devscripts/8483 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Michael Palimaka (kensington)
2012-11-06 11:42:29 UTC
(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. |