summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-11-20 00:17:57 +0000
committerdteske <dteske@FreeBSD.org>2013-11-20 00:17:57 +0000
commitf5ceacf868700bb21302cc4c12fb054f1c2235cc (patch)
tree676aab89623166e7bb2643b01e01a4428f739369 /usr.sbin
parent2e7b9532a0426399328624034dfa2a1482231f3f (diff)
downloadFreeBSD-src-f5ceacf868700bb21302cc4c12fb054f1c2235cc.zip
FreeBSD-src-f5ceacf868700bb21302cc4c12fb054f1c2235cc.tar.gz
Whitespace, style, sub-shells, and standardize variable name
(s/interfaces/menu_list/).
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bsdconfig/networking/share/device.subr46
1 files changed, 20 insertions, 26 deletions
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr
index ca2591e..1d7618e 100644
--- a/usr.sbin/bsdconfig/networking/share/device.subr
+++ b/usr.sbin/bsdconfig/networking/share/device.subr
@@ -62,6 +62,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
#
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=$?
OpenPOWER on IntegriCloud