From owner-freebsd-rc@FreeBSD.ORG Mon May 9 17:12:45 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 7ADFC106566B for ; Mon, 9 May 2011 17:12:45 +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 3ACDA8FC16 for ; Mon, 9 May 2011 17:12:45 +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 p49HBlp3007002 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Mon, 9 May 2011 11:11:49 -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:11:41 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <92B456D2-9EF2-4F1A-8F06-8FFBB44F59B5@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:11:49 -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:12:45 -0000 Isn't printf located in /usr, and isn't /usr not guaranteed to be around = when these routines are used? 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. >=20 > It may be faster to use printf directly but the function is useful for > compatibility. >=20 > Index: etc/network.subr > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- 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" > } >=20 > # hexprint arg > # Echo decimal number $arg (multiple digits) in hexadecimal = format. > hexprint() > { > - local val str dig > - val=3D$1 > - str=3D'' > - dig=3D`hexdigit $((${val} & 15))` > - str=3D${dig}${str} > - val=3D$((${val} >> 4)) > - > - while [ ${val} -gt 0 ]; do > - dig=3D`hexdigit $((${val} & 15))` > - str=3D${dig}${str} > - val=3D$((${val} >> 4)) > - done > - > - echo ${str} > + printf '%x\n' "$1" > } >=20 > is_wired_interface() >=20 > --=20 > 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" >=20 >=20