From 405bc5d791ceb8b04081c99600eea8fae79127ee Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Fri, 18 Sep 2015 09:39:36 -0700
Subject: [PATCH] Make job name command options more consistent

The "scontrol hold/release" commands accept either "name=" or "jobname=". I've modified the documentation to only show "jobname" for consistentcy with the "scontrol update" command.

I have also modified the "scancel" command to accept "--jobname=" in addition to the existing "--name=" and "-n".
---
 doc/man/man1/scancel.1  |  2 +-
 doc/man/man1/scontrol.1 |  9 ++++++---
 src/scancel/opt.c       | 16 ++++++++++++----
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/doc/man/man1/scancel.1 b/doc/man/man1/scancel.1
index dea3a1e050b..f1af4826f04 100644
--- a/doc/man/man1/scancel.1
+++ b/doc/man/man1/scancel.1
@@ -56,7 +56,7 @@ Interactive mode. Confirm each job_id.step_id before performing the cancel opera
 Cluster to issue commands to.
 
 .TP
-\fB\-n\fR, \fB\-\-name\fR=\fIjob_name\fR
+\fB\-n\fR, \fB\-\-jobname\fR=\fIjob_name\fR, \fB\-\-name\fR=\fIjob_name\fR
 Restrict the scancel operation to jobs with this job name.
 
 .TP
diff --git a/doc/man/man1/scontrol.1 b/doc/man/man1/scontrol.1
index eed068c6b30..9e2abd633c9 100644
--- a/doc/man/man1/scontrol.1
+++ b/doc/man/man1/scontrol.1
@@ -191,7 +191,9 @@ This is the default behavior.
 \fBhold\fP \fIjob_list\fP
 Prevent a pending job from beginning started (sets it's priority to 0).
 Use the \fIrelease\fP command to permit the job to be scheduled.
-The job_list argument is a comma separated list of job IDs.
+The job_list argument is a comma separated list of job IDs OR
+"jobname=" with the job's name, which will attempt to hold all jobs having
+that name.
 Note that when a job is held by a system administrator using the \fBhold\fP
 command, only a system administrator may release the job for execution (also
 see the \fBuhold\fP command). When the job is held by its owner, it may also
@@ -275,8 +277,9 @@ or removed from the cluster.
 .TP
 \fBrelease\fP \fIjob_list\fP
 Release a previously held job to begin execution.
-The job_list argument is a comma separated list of job IDs. It is possible to
-use the job name, specifying "name=job_name".
+The job_list argument is a comma separated list of job IDs OR
+"jobname=" with the job's name, which will attempt to hold all jobs having
+that name.
 Also see \fBhold\fR.
 
 .TP
diff --git a/src/scancel/opt.c b/src/scancel/opt.c
index 32082c5e22d..c708041f278 100644
--- a/src/scancel/opt.c
+++ b/src/scancel/opt.c
@@ -362,8 +362,8 @@ static void _opt_env(void)
  */
 static void _opt_args(int argc, char **argv)
 {
-	int opt_char;
-	int option_index;
+	char **rest = NULL;
+	int i, opt_char, option_index;
 	static struct option long_options[] = {
 		{"account",	required_argument, 0, 'A'},
 		{"batch",	no_argument,       0, 'b'},
@@ -372,6 +372,7 @@ static void _opt_args(int argc, char **argv)
 		{"interactive", no_argument,       0, 'i'},
 		{"cluster",     required_argument, 0, 'M'},
 		{"clusters",    required_argument, 0, 'M'},
+		{"jobname",     required_argument, 0, 'n'},
 		{"name",        required_argument, 0, 'n'},
 		{"nodelist",    required_argument, 0, 'w'},
 		{"partition",   required_argument, 0, 'p'},
@@ -464,10 +465,17 @@ static void _opt_args(int argc, char **argv)
 		}
 	}
 
-	if (optind < argc) {
-		char **rest = argv + optind;
+	if (optind < argc)
+		rest = argv + optind;
+	if (rest && (rest[0][0] >= '0') && (rest[0][0] <= '9')) {
 		opt.job_list = rest;
 		_xlate_job_step_ids(rest);
+	} else if (rest) {
+		for (i = optind; i < argc; i++) {
+			if (opt.job_name)
+				xstrcat(opt.job_name, ",");
+			xstrcat(opt.job_name, argv[i]);
+		}
 	}
 
 	if (!_opt_verify())
-- 
GitLab