Make tc and ip batch mode consistent

Change the code for tc and ip so that batch mode is handled
the same.
diff --git a/include/utils.h b/include/utils.h
index 2bd8c62..24ff19f 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -19,6 +19,7 @@
 extern int timestamp;
 extern char * _SL_;
 extern int max_flush_loops;
+extern int batch_mode;
 
 #ifndef IPPROTO_ESP
 #define IPPROTO_ESP	50
diff --git a/ip/ip.c b/ip/ip.c
index 69bd5ff..86f8b45 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -30,9 +30,9 @@
 int oneline = 0;
 int timestamp = 0;
 char * _SL_ = NULL;
-char *batch_file = NULL;
 int force = 0;
 int max_flush_loops = 10;
+int batch_mode = 0;
 
 struct rtnl_handle rth = { .fd = -1 };
 
@@ -113,6 +113,8 @@
 	size_t len = 0;
 	int ret = EXIT_SUCCESS;
 
+	batch_mode = 1;
+
 	if (name && strcmp(name, "-") != 0) {
 		if (freopen(name, "r", stdin) == NULL) {
 			fprintf(stderr, "Cannot open file \"%s\" for reading: %s\n",
@@ -153,6 +155,7 @@
 int main(int argc, char **argv)
 {
 	char *basename;
+	char *batch_file = NULL;
 
 	basename = strrchr(argv[0], '/');
 	if (basename == NULL)
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 5b911f7..794a498 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -42,8 +42,6 @@
 #define MS_SHARED	(1 << 20)
 #endif
 
-extern char *batch_file;
-
 #ifndef HAVE_SETNS
 static int setns(int fd, int nstype)
 {
@@ -190,7 +188,7 @@
 
 	fflush(stdout);
 
-	if (batch_file) {
+	if (batch_mode) {
 		int status;
 		pid_t pid;
 
diff --git a/tc/tc.c b/tc/tc.c
index 8e362d2..9b50e74 100644
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -34,6 +34,7 @@
 int show_details = 0;
 int show_raw = 0;
 int show_pretty = 0;
+int batch_mode = 0;
 
 int resolve_hosts = 0;
 int use_iec = 0;
@@ -220,6 +221,7 @@
 	size_t len = 0;
 	int ret = 0;
 
+	batch_mode = 1;
 	if (name && strcmp(name, "-") != 0) {
 		if (freopen(name, "r", stdin) == NULL) {
 			fprintf(stderr, "Cannot open file \"%s\" for reading: %s\n",
@@ -262,8 +264,7 @@
 int main(int argc, char **argv)
 {
 	int ret;
-	int do_batching = 0;
-	char *batchfile = NULL;
+	char *batch_file = NULL;
 
 	while (argc > 1) {
 		if (argv[1][0] != '-')
@@ -288,10 +289,10 @@
 		} else if (matches(argv[1], "-force") == 0) {
 			++force;
 		} else 	if (matches(argv[1], "-batch") == 0) {
-			do_batching = 1;
-			if (argc > 2)
-				batchfile = argv[2];
 			argc--;	argv++;
+			if (argc <= 1)
+				usage();
+			batch_file = argv[1];
 		} else {
 			fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n", argv[1]);
 			return -1;
@@ -299,8 +300,8 @@
 		argc--;	argv++;
 	}
 
-	if (do_batching)
-		return batch(batchfile);
+	if (batch_file)
+		return batch(batch_file);
 
 	if (argc <= 1) {
 		usage();