On Mon, Oct 11, 2004 at 08:19:21PM +0200, Michal Kochanowicz wrote:
> Hej
> 
> Będę się trochę czepiał, nie widzę że takie rozwiązania już były w tym
> pliku, więc nie bierz do siebie.
> 
> On Mon, Oct 11, 2004 at 08:05:00PM +0200, Przemysław Białek wrote:
> >  
> > +           # check if devfs (workaround: -a option don't work at all)
> > +           if [ -d /dev/vc ]; then
> > +                   DEVICES="`ls /dev/vc/* | sed 's|/dev/vc/||g'`"
> Hej, no ale z tym sed'em tutaj to lekkie przegięcie :/ Nie lepiej zrobić
> tak:
> DEVICES="`cd /dev/vc; ls `"
> ?
Tutaj akurat przeniosłem kawałek który występował wewnątrz if'a.

> 
> 
> > +                   pattern="s/\/dev\/vc\///g"
> > +                   VC_PATH="/dev/vc/"
> > +           else
> > +                   DEVICES="`cat /etc/inittab | grep '^[0-9]*:' | cut -f1 -d :`"
> > +                   pattern="s/\/dev\/tty//g"
> > +                   VC_PATH="/dev/tty"
> > +           fi
> > +
> >             # don't initialize on multiple terminals if we use fbset
> >             # (assume that, in this case fb is loaded as a module)
> >             if [ ! -z "$FB" ]; then
> > -                   # Check for devfs (workaround: -a option don't work at all)
> To też można bez sed:
j.w.

> > -                   if [ -d /dev/vc ]; then
> > -                           pattern="s/\/dev\/vc\///g"
>                               pattern='/dev/vc'
> > -                   else
> > -                           pattern="s/\/dev\/tty//g"
>                               pattern='/dev/tty'
> > -                   fi
> > -
> >                     # save old tty number
> >                     tty=`/usr/bin/tty | sed $pattern`
>                       tty=`/usr/bin/tty`
>                       tty=${tty#$pattern}
> 
> Albo wogóle tak:
> tty=`/usr/bin/tty`
> tty=${tty##/*/}
Można, tylko już w takie rzeczy się nie bawiłem, nie byłem pewien jak takie
rzeczy się poza bashem zachowują, więc nawet nie próbowałem eksperymentować.
> 
> BTW, ciekawe czy i powyższego nie da się uprościć.
> 
> itd... trochę nie chce mi się całości przeglądać, ale myślę że używanie
> sed'a do tak prostych rzeczy, to overkill - i strata czasu (procesora).
Teraz masz też w ten sposób robione i nie narzekasz ;).

W załączeniu diffy z twoimi poprawkami :).

-- 
Pozdrawiam
Przemysław Białek

--- kbd.init.orig       2004-06-28 21:24:23.000000000 +0200
+++ kbd.init    2004-10-11 20:44:49.378048752 +0200
@@ -49,36 +49,30 @@
                show "Loading console font and map"
                busy
 
+               # check if devfs (workaround: -a option don't work at all)
+               if [ -d /dev/vc ]; then
+                       DEVICES="`cd /dev/vc; ls `"
+                       VC_PATH="/dev/vc/"
+               else
+                       DEVICES="`cat /etc/inittab | grep '^[0-9]*:' | cut -f1 -d :`"
+                       VC_PATH="/dev/tty"
+               fi
+
                # don't initialize on multiple terminals if we use fbset
                # (assume that, in this case fb is loaded as a module)
                if [ ! -z "$FB" ]; then
-                       # Check for devfs (workaround: -a option don't work at all)
-                       if [ -d /dev/vc ]; then
-                               pattern="s/\/dev\/vc\///g"
-                       else
-                               pattern="s/\/dev\/tty//g"
-                       fi
-
                        # save old tty number
-                       tty=`/usr/bin/tty | sed $pattern`
-
-                       # check if devfs (workaround: -a option don't work at all)
-                       if [ -d /dev/vc ]; then
-                               DEVICES="`ls /dev/vc/* | sed 's|/dev/vc/||g'`"
-                       else
-                               DEVICES="`cat /etc/inittab | grep '^[0-9]*:' | cut -f1 
-d :`"
-                       fi
+                       tty=`/usr/bin/tty`
+                       tty=${tty##/*/}
 
                        [ -z "$SET_FONT_TERMINALS" ] && SET_FONT_TERMINALS="$DEVICES"
 
                        for cons in $SET_FONT_TERMINALS; do
                                /usr/bin/open -c $cons -s -w -- $CMD
-                               if [ "$NUM_LOCK" ]; then
-                                       if [ $NUM_LOCK = "on" ]; then
-                                               /usr/bin/open -c $cons -s -w -- 
/usr/bin/setleds -D +num
-                                       else
-                                               /usr/bin/open -c $cons -s -w -- 
/usr/bin/setleds -D -num
-                                       fi
+                               if is_yes "$NUM_LOCK"; then
+                                       /usr/bin/open -c $cons -s -w -- 
/usr/bin/setleds -D +num
+                               else
+                                       /usr/bin/open -c $cons -s -w -- 
/usr/bin/setleds -D -num
                                fi
                        done
 
@@ -87,6 +81,11 @@
                        fi
                        /usr/bin/switchto $tty
                else
+                       if is_yes "$NUM_LOCK"; then
+                               for cons in $DEVICES; do
+                                       /usr/bin/setleds -D +num < $VC_PATH$cons
+                               done
+                       fi
                        $CMD
                fi
                ok
--- kbd.init.orig       2004-06-28 21:24:23.000000000 +0200
+++ kbd.init    2004-10-11 20:41:07.852725720 +0200
@@ -49,36 +49,30 @@
                show "Loading console font and map"
                busy
 
+               # check if devfs (workaround: -a option don't work at all)
+               if [ -d /dev/vc ]; then
+                       DEVICES="`cd /dev/vc; ls `"
+                       VC_PATH="/dev/vc/"
+               else
+                       DEVICES="`cat /etc/inittab | grep '^[0-9]*:' | cut -f1 -d :`"
+                       VC_PATH="/dev/tty"
+               fi
+
+               [ -z "$SET_FONT_TERMINALS" ] && SET_FONT_TERMINALS="$DEVICES"
+
                # don't initialize on multiple terminals if we use fbset
                # (assume that, in this case fb is loaded as a module)
                if [ ! -z "$FB" ]; then
-                       # Check for devfs (workaround: -a option don't work at all)
-                       if [ -d /dev/vc ]; then
-                               pattern="s/\/dev\/vc\///g"
-                       else
-                               pattern="s/\/dev\/tty//g"
-                       fi
-
                        # save old tty number
-                       tty=`/usr/bin/tty | sed $pattern`
-
-                       # check if devfs (workaround: -a option don't work at all)
-                       if [ -d /dev/vc ]; then
-                               DEVICES="`ls /dev/vc/* | sed 's|/dev/vc/||g'`"
-                       else
-                               DEVICES="`cat /etc/inittab | grep '^[0-9]*:' | cut -f1 
-d :`"
-                       fi
-
-                       [ -z "$SET_FONT_TERMINALS" ] && SET_FONT_TERMINALS="$DEVICES"
+                       tty=`/usr/bin/tty`
+                       tty=${tty##/*/}
 
                        for cons in $SET_FONT_TERMINALS; do
                                /usr/bin/open -c $cons -s -w -- $CMD
-                               if [ "$NUM_LOCK" ]; then
-                                       if [ $NUM_LOCK = "on" ]; then
-                                               /usr/bin/open -c $cons -s -w -- 
/usr/bin/setleds -D +num
-                                       else
-                                               /usr/bin/open -c $cons -s -w -- 
/usr/bin/setleds -D -num
-                                       fi
+                               if is_yes "$NUM_LOCK"; then
+                                       /usr/bin/open -c $cons -s -w -- 
/usr/bin/setleds -D +num
+                               else
+                                       /usr/bin/open -c $cons -s -w -- 
/usr/bin/setleds -D -num
                                fi
                        done
 
@@ -87,6 +81,11 @@
                        fi
                        /usr/bin/switchto $tty
                else
+                       if is_yes "$NUM_LOCK"; then
+                               for cons in $SET_FONT_TERMINALS; do
+                                       /usr/bin/setleds -D +num < $VC_PATH$cons
+                               done
+                       fi
                        $CMD
                fi
                ok
_______________________________________________
pld-devel-pl mailing list
[EMAIL PROTECTED]
http://lists.pld-linux.org/mailman/listinfo/pld-devel-pl

Odpowiedź listem elektroniczym