[Pkg-sysvinit-devel] Bug#406393: rc script: avoiding use of Sed

Ivan Baldo ibaldo at adinet.com.uy
Wed Jan 10 21:44:45 CET 2007


Package: sysv-rc
Version: 2.86.ds1-36
Severity: wishlist
Tags: patch

One can detect the priority level of an init script with:
  level=${s#/etc/rc$runlevel.d/S}
  level=${level%%[a-z]*}

That should be faster than using sed because sed is an external program and a
complex one by the way.
I wasn't able to measure any speedup, maybe because the time is dominated by
other things but maybe it helps on slow processors or lower memory systems.
This works with Bash and Dash, tested it on both and I maked sure that the new
way is identical to the old one in behaviour.
I guess its too late for Etch but anyway...
Thank you.

P.s.: I see that initscripts are incorporating special comments to declare
dependencies, is there any aproximative timeline as to when that information
will start to be used and will be required by all initscripts?

--- rc.original 2007-01-10 17:10:43.000000000 -0200
+++ rc.ivan     2007-01-10 17:20:15.000000000 -0200
@@ -247,7 +247,8 @@
                CURLEVEL=""
                for s in /etc/rc$runlevel.d/K*
                do
-                       level=$(echo $s | sed 's/.*\/K\([0-9][0-9]\).*/\1/')
+                       level=${s#/etc/rc$runlevel.d/K}
+                       level=${level%%[a-z]*}
                        if [ "$level" = "$CURLEVEL" ]
                        then
                                continue
@@ -285,7 +286,8 @@
        CURLEVEL=""
        for s in /etc/rc$runlevel.d/S*
        do
-               level=$(echo $s | sed 's/.*\/S\([0-9][0-9]\).*/\1/')
+               level=${s#/etc/rc$runlevel.d/S}
+               level=${level%%[a-z]*}
                if [ "$level" = "$CURLEVEL" ]
                then
                        continue


-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.19.1
Locale: LANG=es_UY, LC_CTYPE=es_UY (charmap=ISO-8859-1)

sysv-rc depends on no packages.

Versions of packages sysv-rc recommends:
ii  lsb-base                      3.1-22     Linux Standard Base 3.1 init scrip

-- no debconf information




More information about the Pkg-sysvinit-devel mailing list