#417: bashism in "#!/bin/sh" scripts (rtirq, 64studio-skel, 64studio-themes, others?)
#417: bashism in "#!/bin/sh" scripts (rtirq, 64studio-skel, 64studio-themes,
others?)
------------------------------+---------------------------------------------
Reporter: emarsk@gmail.com | Owner: free
Type: defect | Status: new
Priority: normal | Milestone:
Component: build | Version:
Severity: normal | Keywords:
------------------------------+---------------------------------------------
/etc/init.d/rtirq (from package rtirq) is a "#!/bin/sh" script, but uses a
bash-only "function" syntax, not supported by dash ('fuction foo ()'
instead of 'foo ()').
FIX:
{{{
sed -i "s/^function //" /etc/init.d/rtirq
}}}
Similarly, upgrading gave me these two errors, caused by bashism ('[
"$blah" == "" ]' instead of '[ "$blah" = "" ]' in postinst scripts):
{{{
Setting up 64studio-skel (2.1~pre14) ...
[: 38: ==: unexpected operator
Setting up 64studio-themes (2.1~pre14) ...
[: 48: ==: unexpected operator
}}}
FIX:[[BR]]
in each deb package:
{{{
sed -i "s/==/=/" debian/postinst
}}}
RATIONALE:[[BR]]
Scripts that use "#!bin/sh" must be POSIX compliant and they should be
tested with dash, which is lighter and faster than bash (and thus a better
choice as a script interpreter), and POSIX compliant as opposed to
bash.[[BR]]
If a script 'really' needs some bash-only syntax it should use
"#!/bin/bash", otherwise it's better to stick with dash syntax (which of
course is bash-compatible as it's a subset).[[BR]]
It should be noted that debconf, when installing dash, asks whether to
link it to /bin/sh or not, of course expecting that no script breaks the
aforementioned rule.
Slán
-- Emanuele --
--
Ticket URL: <http://trac.64studio.com/64studio/ticket/417>
64 Studio <>
_______________________________________________
64studio-devel mailing list
64studio-devel@64studio.com
http://lists.64studio.com/mailman/listinfo/64studio-devel
|