Subject: [patch] [iproute] ip exit, ip and tc line number

From: Michele Petrazzo - Unipex <[email-masked]>
Date: Tue, 02 Mar 2010 19:28:41 +0100

Hi,
I create a small patch that solve an annoying problem that I found on 
"ip -batch" usage, so the command exits without end the parsing of the 
batch file also if I specify the -force switch.
Also add the shown of the right line number where batch file fail for 
both ip and tc

Michele
commit 805fac22865d50b561643e58f5c2c001439a6a7d
Author: Michele Petrazzo <[email-masked]>
Date:   Tue Mar 2 19:12:50 2010 +0100

    Resolving "ip" exit on batch usage and add to ip and tc commands
    the right line number on the output message then use with batch
    switch
    
    Signed-off-by: Michele Petrazzo <[email-masked]>

diff --git a/ip/ip.c b/ip/ip.c
index ace8cc6..b8c4914 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -125,6 +125,9 @@ static int batch(const char *name)
 			if (!force)
 				break;
 		}
+        else {
+            lineno++;
+        }
 	}
 	if (line)
 		free(line);
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index e9256d9..8ec6cfd 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1014,7 +1014,7 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
 	}
 	if (l && matches(d, l) != 0) {
 		fprintf(stderr, "\"dev\" (%s) must match \"label\" (%s).\n", d, l);
-		exit(1);
+		return -1;
 	}
 
 	if (peer_len == 0 && local_len) {
@@ -1079,7 +1079,7 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
 	}
 
 	if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
-		exit(2);
+		return -2;
 
 	return 0;
 }
diff --git a/tc/tc.c b/tc/tc.c
index 8e362d2..ce78621 100644
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -250,6 +250,11 @@ static int batch(const char *name)
 			if (!force)
 				break;
 		}
+        else {
+            cmdlineno++;
+        }
+           
+
 	}
 	if (line)
 		free(line);