From 454f78e65f74634e2ce7265fba87890db5fdd1a4 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Tue, 2 Jun 2015 10:37:09 -0700
Subject: [PATCH] Fix issue where command line options were parsed twice in
 sbatch.

---
 NEWS             |  1 +
 src/sbatch/opt.c | 16 +++++-----------
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/NEWS b/NEWS
index 714aa35a5e5..1ae462cc27c 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,7 @@ documents those changes that are of interest to users and administrators.
     corruption if thread uses the pointer basing validity off the id.
  -- Fix issue where sbatch would set ntasks-per-node to 0 making any srun
     afterward cause a divide by zero error.
+ -- Fix issue where command line options were parsed twice in sbatch.
 
 * Changes in Slurm 14.11.7
 ==========================
diff --git a/src/sbatch/opt.c b/src/sbatch/opt.c
index 21a15b33878..ee753eeb475 100644
--- a/src/sbatch/opt.c
+++ b/src/sbatch/opt.c
@@ -1160,8 +1160,7 @@ static void _set_options(int argc, char **argv)
 				       optz, &option_index)) != -1) {
 		switch (opt_char) {
 		case '?':
-			error("Try \"sbatch --help\" for more information");
-			exit(error_exit);
+			/* handled in process_options_first_pass() */
 			break;
 		case 'a':
 			xfree(opt.array_inx);
@@ -1233,8 +1232,8 @@ static void _set_options(int argc, char **argv)
 				exit(error_exit);
 			break;
 		case 'h':
-			_help();
-			exit(0);
+			/* handled in process_options_first_pass() */
+			break;
 		case 'H':
 			opt.hold = true;
 			break;
@@ -1313,7 +1312,7 @@ static void _set_options(int argc, char **argv)
 			opt.dependency = xstrdup(optarg);
 			break;
 		case 'Q':
-			opt.quiet++;
+			/* handled in process_options_first_pass() */
 			break;
 		case 'R':
 			opt.no_rotate = true;
@@ -1329,14 +1328,9 @@ static void _set_options(int argc, char **argv)
 			opt.time_limit_str = xstrdup(optarg);
 			break;
 		case 'u':
-			_usage();
-			exit(0);
 		case 'v':
-			opt.verbose++;
-			break;
 		case 'V':
-			print_slurm_version();
-			exit(0);
+			/* handled in process_options_first_pass() */
 			break;
 		case 'w':
 			xfree(opt.nodelist);
-- 
GitLab