Ticket #417 (new defect)

Opened 3 months ago

Last modified 3 months ago

bashism in "#!/bin/sh" scripts (rtirq, 64studio-skel, 64studio-themes, others?)

Reported by: emarsk@gmail.com Assigned to: free
Priority: normal Milestone: 2.2
Component: build Version: 2.0
Severity: normal Keywords:
Cc:

Description

/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:
in each deb package:

 sed -i "s/==/=/" debian/postinst

RATIONALE:
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.
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).
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 --

Change History

04/29/08 10:32:08 changed by daniel@64studio.com

  • version set to 2.0.
  • milestone set to 2.2.