From owner-freebsd-rc@FreeBSD.ORG Sun May 8 12:37:47 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 97907106566C for ; Sun, 8 May 2011 12:37:47 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 3EB688FC08 for ; Sun, 8 May 2011 12:37:47 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 4292335932A for ; Sun, 8 May 2011 14:37:46 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 2BEAE17376; Sun, 8 May 2011 14:37:46 +0200 (CEST) Date: Sun, 8 May 2011 14:37:46 +0200 From: Jilles Tjoelker To: freebsd-rc@FreeBSD.org Message-ID: <20110508123745.GA83320@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Subject: [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: Sun, 08 May 2011 12:37:47 -0000 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