From owner-freebsd-rc@FreeBSD.ORG Mon May 9 17:21:35 2011 Return-Path: Delivered-To: freebsd-rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 08ECD106566B for ; Mon, 9 May 2011 17:21:35 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id BCFF18FC08 for ; Mon, 9 May 2011 17:21:34 +0000 (UTC) Received: from [10.30.101.52] ([209.117.142.2]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p49HEEbu007032 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Mon, 9 May 2011 11:14:15 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <20110508123745.GA83320@stack.nl> Date: Mon, 9 May 2011 11:14:08 -0600 Content-Transfer-Encoding: 7bit Message-Id: <8F50A4FE-C2CC-4898-809E-A9A43F1C2079@bsdimp.com> References: <20110508123745.GA83320@stack.nl> To: Jilles Tjoelker X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Mon, 09 May 2011 11:14:15 -0600 (MDT) Cc: freebsd-rc@FreeBSD.org Subject: Re: [PATCH] Use printf(1) builtin for hexprint function in etc/network.subr X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2011 17:21:35 -0000 Missed that it is now a shell built-in. N/m about my comments. Warner On May 8, 2011, at 6:37 AM, Jilles Tjoelker wrote: > Now that printf(1) is a shell builtin, there is no need to emulate it > anymore. > > It may be faster to use printf directly but the function is useful for > compatibility. > > Index: etc/network.subr > =================================================================== > --- etc/network.subr (revision 220966) > +++ etc/network.subr (working copy) > @@ -1333,38 +1333,14 @@ > # Echo decimal number $arg (single digit) in hexadecimal format. > hexdigit() > { > - if [ $1 -lt 10 ]; then > - echo $1 > - else > - case $1 in > - 10) echo a ;; > - 11) echo b ;; > - 12) echo c ;; > - 13) echo d ;; > - 14) echo e ;; > - 15) echo f ;; > - esac > - fi > + printf '%x\n' "$1" > } > > # hexprint arg > # Echo decimal number $arg (multiple digits) in hexadecimal format. > hexprint() > { > - local val str dig > - val=$1 > - str='' > - dig=`hexdigit $((${val} & 15))` > - str=${dig}${str} > - val=$((${val} >> 4)) > - > - while [ ${val} -gt 0 ]; do > - dig=`hexdigit $((${val} & 15))` > - str=${dig}${str} > - val=$((${val} >> 4)) > - done > - > - echo ${str} > + printf '%x\n' "$1" > } > > is_wired_interface() > > -- > Jilles Tjoelker > _______________________________________________ > freebsd-rc@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-rc > To unsubscribe, send any mail to "freebsd-rc-unsubscribe@freebsd.org" > >