From owner-svn-src-head@FreeBSD.ORG Wed Nov 20 00:17:58 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 320F5D78; Wed, 20 Nov 2013 00:17:58 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 125AB287D; Wed, 20 Nov 2013 00:17:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAK0HvLO040322; Wed, 20 Nov 2013 00:17:57 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAK0Hvm6040321; Wed, 20 Nov 2013 00:17:57 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201311200017.rAK0Hvm6040321@svn.freebsd.org> From: Devin Teske Date: Wed, 20 Nov 2013 00:17:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258360 - head/usr.sbin/bsdconfig/networking/share X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Nov 2013 00:17:58 -0000 Author: dteske Date: Wed Nov 20 00:17:57 2013 New Revision: 258360 URL: http://svnweb.freebsd.org/changeset/base/258360 Log: Whitespace, style, sub-shells, and standardize variable name (s/interfaces/menu_list/). Modified: head/usr.sbin/bsdconfig/networking/share/device.subr Modified: head/usr.sbin/bsdconfig/networking/share/device.subr ============================================================================== --- head/usr.sbin/bsdconfig/networking/share/device.subr Tue Nov 19 23:37:50 2013 (r258359) +++ head/usr.sbin/bsdconfig/networking/share/device.subr Wed Nov 20 00:17:57 2013 (r258360) @@ -62,6 +62,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/inc # f_dialog_menu_netdev() { + local menu_list # Calculated below local defaultitem="${1%\*}" # Trim trailing asterisk if present # @@ -74,19 +75,15 @@ f_dialog_menu_netdev() # Get list of usable network interfaces # local d='[[:digit:]]+:' - local iflist="`echo "$(ifconfig -l):" | sed -E -e " - # Convert all spaces to colons - y/ /:/ - - # Prune unsavory interfaces - s/lo$d//g - s/ppp$d//g - s/sl$d//g - s/faith$d//g - - # Convert all colons back into spaces - y/:/ / - "`" + local if iflist= # Calculated below + for if in $( ifconfig -l ); do + # Skip unsavory interfaces + case "$if" in + lo[0-9]*|ppp[0-9]*|sl[0-9]*|faith[0-9]*) continue ;; + esac + iflist="$iflist $if" + done + iflist="${iflist# }" # # Optionally kick interfaces in the head to get them to accurately @@ -110,20 +107,17 @@ f_dialog_menu_netdev() # Mark any "active" interfaces with an asterisk (*) # to the right of the device name. # - interfaces=$( + menu_list=$( for ifn in $iflist; do - active=$( ifconfig $ifn | awk \ - ' - ( $1 == "status:" ) \ - { - if ( $2 == "active" ) { print 1; exit } - } - ' ) + active=$( ifconfig $ifn 2> /dev/null | awk ' + ($1 == "status:") { + if ($2 == "active") { print 1; exit } + }' ) printf "'%s%s' '%s'\n" \ $ifn "${active:+*}" "$( f_device_desc $ifn )" done ) - if [ ! "$interfaces" ]; then + if [ ! "$menu_list" ]; then f_show_msg "$msg_no_network_interfaces" return $DIALOG_CANCEL fi @@ -132,8 +126,8 @@ f_dialog_menu_netdev() # Maybe the default item was marked as active # if [ "$defaultitem" ]; then - ifconfig "$defaultitem" 2> /dev/null | awk \ - '( $1 == "status:" && $2 != "active" ) { exit 0 }' || + ifconfig "$defaultitem" 2> /dev/null | + awk '($1 == "status:" && $2 == "active"){exit 1}' || defaultitem="$defaultitem*" fi @@ -149,7 +143,7 @@ f_dialog_menu_netdev() \"\$DIALOG_BACKTITLE\" \ \"\$prompt\" \ \"\$hline\" \ - $interfaces + $menu_list local menu_choice menu_choice=$( eval $DIALOG \ --title \"\$DIALOG_TITLE\" \ @@ -160,7 +154,7 @@ f_dialog_menu_netdev() --default-item \"\$defaultitem\" \ --menu \"\$prompt\" \ $height $width $rows \ - $interfaces \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$?