From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 18 20:33:57 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 8329816A400 for ; Tue, 18 Apr 2006 20:33:57 +0000 (UTC) (envelope-from gbergling@0xfce3.net) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5784243D46 for ; Tue, 18 Apr 2006 20:33:55 +0000 (GMT) (envelope-from gbergling@0xfce3.net) X-Envelope-From: gbergling@0xfce3.net Received: from central.0xfce3.net (dslb-088-072-033-140.pools.arcor-ip.net [88.72.33.140]) (authenticated bits=128) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id k3IKXi0s014338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 18 Apr 2006 22:33:45 +0200 Received: from central.0xfce3.net (localhost [127.0.0.1]) by central.0xfce3.net (8.13.6/8.13.4) with ESMTP id k3IKXaBR019213; Tue, 18 Apr 2006 22:33:36 +0200 (CEST) (envelope-from gbergling@0xfce3.net) Received: (from gordon@localhost) by central.0xfce3.net (8.13.6/8.13.4/Submit) id k3IKXXN7019212; Tue, 18 Apr 2006 22:33:33 +0200 (CEST) (envelope-from gbergling@0xfce3.net) X-Authentication-Warning: central.0xfce3.net: gordon set sender to gbergling@0xfce3.net using -f Date: Tue, 18 Apr 2006 22:33:33 +0200 From: Gordon Bergling To: Eric Anderson Message-ID: <20060418203333.GA19094@central.0xfce3.net> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <444545D3.5010405@centtech.com> X-Url: X-Operating-System: FreeBSD 6.1-RC i386 X-Host-Uptime: 10:32PM up 13:36, 0 users, load averages: 0.02, 0.02, 0.00 User-Agent: Mutt/1.5.11 X-Spam-Score: * (1.426) AWL,BAYES_50,FORGED_RCVD_HELO X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 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:33:57 -0000 * 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" ;) -- Gordon Bergling http://www.0xFCE3.net/ PGP Fingerprint: 7732 9BB1 5013 AE8B E42C 28E0 93B9 D32B C76F 02A0 RIPE-HDL: MDTP-RIPE "Minimal Electronic Music"