From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 18 20:35:58 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7D30216A468 for ; Tue, 18 Apr 2006 20:35:58 +0000 (UTC) (envelope-from anderson@centtech.com) Received: from mh2.centtech.com (moat3.centtech.com [207.200.51.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id CEA7643D58 for ; Tue, 18 Apr 2006 20:35:51 +0000 (GMT) (envelope-from anderson@centtech.com) Received: from [10.177.171.220] (neutrino.centtech.com [10.177.171.220]) by mh2.centtech.com (8.13.1/8.13.1) with ESMTP id k3IKZkCJ014006; Tue, 18 Apr 2006 15:35:46 -0500 (CDT) (envelope-from anderson@centtech.com) Message-ID: <44454D96.3030004@centtech.com> Date: Tue, 18 Apr 2006 15:35:34 -0500 From: Eric Anderson User-Agent: Thunderbird 1.5 (X11/20060402) MIME-Version: 1.0 To: Gordon Bergling References: <444515C8.3030406@centtech.com> <20060418165709.GA17705@central.0xfce3.net> <44452532.40703@centtech.com> <20060418.114933.69380798.imp@bsdimp.com> <346a80220604181102v3597a1edp3e05fa663b87e15c@mail.gmail.com> <20060418193018.GB694@turion.vk2pj.dyndns.org> <444545D3.5010405@centtech.com> <20060418203333.GA19094@central.0xfce3.net> In-Reply-To: <20060418203333.GA19094@central.0xfce3.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.87.1/1405/Tue Apr 18 13:30:25 2006 on mh2.centtech.com X-Virus-Status: Clean Cc: cokane@cokane.org, freebsd-hackers@freebsd.org Subject: Re: [PATCH] Fancy rc startup style RFC X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Apr 2006 20:35:58 -0000 Gordon Bergling wrote: > * Thus spake Eric Anderson (anderson@centtech.com): >> 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. :) Thanks for testing! Eric -- ------------------------------------------------------------------------ Eric Anderson Sr. Systems Administrator Centaur Technology Anything that works is better than anything that doesn't. ------------------------------------------------------------------------