Anish Mistry wrote:
On Tuesday 18 April 2006 16:35, Eric Anderson wrote:
Gordon Bergling wrote:
* Thus spake Eric Anderson ([EMAIL PROTECTED]):
Peter Jeremy wrote:
On Tue, 2006-Apr-18 14:02:07 -0400, Coleman Kane wrote:

A few comments on the shellscript:
+                       rcargsize=`echo $rc_arg`
+                       rcargsize=${#rcargsize}
Try                     rcargsize=$((${#rc_arg} + 1))

-                                   return 1
+                                   (echo_fancy "FAILED" `expr 10 +
$rcargsize - 1`) && return 1
Try                                 echo_fancy "FAILED" $((10 + $rcargsize -
1)) && return 1

+echo_fancy () {
...

+       namesize=`echo -n $name`
+       namesize=${#namesize}
or      namesize=${#name}

+       padding=""
+       paddingsize=$(($columns - 15 - $2 - $namesize))
+       until [ 0 = ${paddingsize} ]; do
+               padding=" $padding"
+               paddingsize=$(($paddingsize - 1))
+       done
This particular block of code appears unnecessary (since
$padding is unused).
I must be missing something, because I'm pretty sure it's used..
What did I miss?

+                       paddingsize=$((60 - $namesize - $rc_argsize))
+                       until [ 0 = ${paddingsize} ]; do
+                               padding=" $padding"
+                               paddingsize=$(($paddingsize - 1))
+                       done
For safety, the conditions should probably be [ 0 -ge
${paddingsize} ] I don't see any alternative to the until loop.
 If efficiency turns out to be a real issue then you could try
doing the expansion in multiple goes.  Eg:

                        until [ 8 -gt ${paddingsize} ]; do
                                padding="        $padding"
                                paddingsize=$(($paddingsize - 8))
                        done
                        until [ 0 -ge ${paddingsize} ]; do
                                padding=" $padding"
                                paddingsize=$(($paddingsize - 1))
                        done
Thanks for the hints.  I was testing the same changes to the
namesize/etc as you suggested, and it does work and is more
readable and more efficient.

I've included your suggestions and put the latest changes here:

http://www.googlebit.com/freebsd/patches/rc_fancy.patch-3
Patch -3 is working good here. :)

best regards,

        Gordon

PS: next try... fancy_color_rc="YES" ;)
If I could figure out how to make sh do colors, I'd do it. :)
Is that all? :)
#!/bin/sh
############################################################
# Nico Golde <nico(at)ngolde.de> Homepage: http://www.ngolde.de
# Last change: Mon Feb 16 16:24:41 CET 2004
############################################################

for attr in 0 1 4 5 7 ; do
echo "----------------------------------------------------------------"
    printf "ESC[%s;Foreground;Background - \n" $attr
    for fore in 30 31 32 33 34 35 36 37; do
        for back in 40 41 42 43 44 45 46 47; do
printf '\033[%s;%s;%sm %02s;%02s ' $attr $fore $back $fore $back
        done
    printf '\n'
    done
    printf '\033[0m'
done

But can you do it without the printf's? That's the key. We don't have printf until later in the boot process..

Eric




--
------------------------------------------------------------------------
Eric Anderson        Sr. Systems Administrator        Centaur Technology
Anything that works is better than anything that doesn't.
------------------------------------------------------------------------
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to