sm-grimoire-bugs AT lists.ibiblio.org
Subject: SourceMage Grimoire Bug List
List archive
[SM-Grimoire-Bugs] [Bug 12859] New: simpleinit-msb's telinit claims to be a sh script but is really a bash script
- From: bugzilla-daemon AT bugs.sourcemage.org
- To: sm-grimoire-bugs AT lists.ibiblio.org
- Subject: [SM-Grimoire-Bugs] [Bug 12859] New: simpleinit-msb's telinit claims to be a sh script but is really a bash script
- Date: 14 Jul 2006 23:39:06 -0000
http://bugs.sourcemage.org/show_bug.cgi?id=12859
Summary: simpleinit-msb's telinit claims to be a sh script but is
really a bash script
Product: Codex
Version: test grimoire
Platform: All
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: smgl
AssignedTo: smgl AT sourcemage.org
ReportedBy: sqweek AT gmail.com
CC: sm-grimoire-bugs AT lists.ibiblio.org
/sbin/telinit:1:#!/bin/sh
The easiest fix is up here of course, just switch it to /bin/bash. But I'll
go
through the deviations just out of curiousity.
/sbin/telinit:24:if [ $UID != 0 ]; then
$UID is a bash extension (can be easily replaced by `id -u`).
/sbin/telinit:29:if [ z"$1" == z"--" ]; then shift 1; fi
== is not a valid operator for /bin/[ (use =)
/sbin/telinit:36:expr "`echo ; cat $INIT_ROOT/etc/inittab`" : $'.*\n[
\r\t]*'${1}$'[ \r\t]*=*[ \r\t]*''\('$'[^ \r\t\n]*''\).*'
The $'\escape-code-madness' notation is a bash extension. Definately the most
touchy part to sh-ify, though you ought to be able to do a pretty faithful
conversion by relacing $'...' with `printf '...'`.
In the patch I'm about to submit I opted to change to a single sed command
instead, which left me with no choice but to use hard tabs (since sh doesn't
have $'', and strictly speaking, sed doesn't accept \t as a tab (that's a GNU
extension)), and drop the \r. But honestly wtf is a CR going to be doing in
there.
I'm not that fussed whether the /bin/bash or sh compatible route is taken,
but
if you stick with /bin/bash you're still left with a bug[1] - the current RE
is
going to run into trouble if any keywords with a common prefix enter into
inittab. [ \r\t]*=*[ \r\t]* will happily match nothing, so if you're looking
up
the keyword PATH and run in to a keyword PATH2, \1 is going to end up
matching "2".
[1] Which is not to say my implementation is infalliable[2], it just doesn't
have any bugs I can see ;)
[2] Though I can guarentee it works against all keywords in the current
inittab
--
Configure bugmail: http://bugs.sourcemage.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
- [SM-Grimoire-Bugs] [Bug 12859] New: simpleinit-msb's telinit claims to be a sh script but is really a bash script, bugzilla-daemon, 07/14/2006
Archive powered by MHonArc 2.6.24.