From 1050fa99adc921b95e0dd57b7af1a9d6352706e0 Mon Sep 17 00:00:00 2001 From: Tom Hey Date: Mon, 16 Feb 2015 22:38:57 +0000 Subject: [PATCH 1/2] Fix debug flag handling (also switch changeInterface debug option to match readInterface) --- changeInterface.awk | 11 ++++++++--- readInterfaces.awk | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/changeInterface.awk b/changeInterface.awk index b50e480..51abcdb 100644 --- a/changeInterface.awk +++ b/changeInterface.awk @@ -15,7 +15,7 @@ function writeStatic(addr, nw, nm, gw) { function usage() { print "awk -f changeInterfaces.awk device= \n" \ " [address=] [gateway=] [netmask=]\n" \ - " [network=] [mode=dhcp|static] [arg=debug]" + " [network=] [mode=dhcp|static] [debug]" } BEGIN { start = 0; @@ -26,6 +26,13 @@ BEGIN { start = 0; } for (i = 2; i < ARGC; i++) { + + if (ARGV[i] == "debug") { + debug = 1; + delete ARGV[i]; + continue; + } + split(ARGV[i], pair, "="); if (pair[1] == "address") address = pair[2]; @@ -37,8 +44,6 @@ BEGIN { start = 0; netmask = pair[2]; else if (pair[1] == "device") device = pair[2]; - else if (pair[1] == "arg" && pair[2] == "debug") - debug = 1; else if (pair[1] == "mode" && pair[2] == "dhcp") dhcp = 1; else if (pair[1] == "mode" && pair[2] == "static") diff --git a/readInterfaces.awk b/readInterfaces.awk index 3124762..51e7717 100644 --- a/readInterfaces.awk +++ b/readInterfaces.awk @@ -6,10 +6,13 @@ BEGIN { start = 0; } for (i = 2; i < ARGC; i++) { - if (ARGV[i] == debug) { + + if (ARGV[i] == "debug") { debug = 1; + delete ARGV[i]; continue; } + split(ARGV[i], arg, "="); if (arg[1] == "device") device = arg[2]; From a56fa977d6e8ded5458e3db448ed98600605ddb3 Mon Sep 17 00:00:00 2001 From: Tom Hey Date: Tue, 17 Feb 2015 22:01:34 +0000 Subject: [PATCH 2/2] Clean-up debug output (removing comment and blank lines) --- readInterfaces.awk | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/readInterfaces.awk b/readInterfaces.awk index 51e7717..abb1e8e 100644 --- a/readInterfaces.awk +++ b/readInterfaces.awk @@ -55,13 +55,24 @@ BEGIN { start = 0; } } + if ($1 == "auto") { + static = 0; + next; + } + + # Skip comment and blank lines + if ($0 ~ /^#/ || + $0 ~ /^[ \t]*$/ ) { + next; + } + # At here, it means we are after the iface static line of # after the device we are searching for # Scan for the static content if (static) { if (debug) - print "static - ", $0, $1; + print $0 if ($1 == "address") { address = $2;