From b6e6d918c0758d5c5acbc9f9e6d53733a748a6d4 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sun, 31 Dec 2000 01:51:23 +0000 Subject: [PATCH] If the first argument doesn't start with '-' assume that it is an interface. This augments the default to an appropriate interface code. # These programs should be merged into ifconfig, ala NetBSD, but that's # a fight for another day. Idea from: OpenBSD --- usr.sbin/ancontrol/ancontrol.c | 9 +++++++-- usr.sbin/wicontrol/wicontrol.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/usr.sbin/ancontrol/ancontrol.c b/usr.sbin/ancontrol/ancontrol.c index 8754063ef00d..f06923596463 100644 --- a/usr.sbin/ancontrol/ancontrol.c +++ b/usr.sbin/ancontrol/ancontrol.c @@ -1342,9 +1342,14 @@ int main(argc, argv) if (ch == 'i') { iface = optarg; } else { - iface = "an0"; + if (argc > 1 && *argv[1] != '-') { + iface = argv[1]; + optind = 2; + } else { + iface = "an0"; + optind = 1; + } optreset = 1; - optind = 1; } opterr = 1; diff --git a/usr.sbin/wicontrol/wicontrol.c b/usr.sbin/wicontrol/wicontrol.c index ecbc2ea9c055..ed774fbda6ce 100644 --- a/usr.sbin/wicontrol/wicontrol.c +++ b/usr.sbin/wicontrol/wicontrol.c @@ -703,9 +703,14 @@ int main(argc, argv) if (ch == 'i') { iface = optarg; } else { - iface = "wi0"; + if (argc > 1 && *argv[1] != '-') { + iface = argv[1]; + optind = 2; + } else { + iface = "wi0"; + optind = 1; + } optreset = 1; - optind = 1; } opterr = 1;