@@ -206,6 +206,7 @@ static void jobid_prune_expedite(void)
* %e = executable
* %g = gid
* %h = hostname
+ * %H = short hostname
* %j = per-session
* %p = pid
* %u = uid
@@ -222,7 +223,7 @@ static int jobid_interpret_string(const char *jobfmt, char *jobid,
char c;
while ((c = *jobfmt++) && joblen > 1) {
- char f;
+ char f, *p;
int l;
if (isspace(c)) /* Don't allow embedded spaces */
@@ -232,6 +233,7 @@ static int jobid_interpret_string(const char *jobfmt, char *jobid,
*jobid = c;
joblen--;
jobid++;
+ *jobid = '\0';
continue;
}
@@ -247,6 +249,15 @@ static int jobid_interpret_string(const char *jobfmt, char *jobid,
l = snprintf(jobid, joblen, "%s",
init_utsname()->nodename);
break;
+ case 'H': /* short hostname. Cut at first dot */
+ l = snprintf(jobid, joblen, "%s",
+ init_utsname()->nodename);
+ p = strnchr(jobid, joblen, '.');
+ if (p) {
+ *p = '\0';
+ l = p - jobid;
+ }
+ break;
case 'j': /* jobid requested by process */
l = snprintf(jobid, joblen, "%s",
jobid_current() ?: "jobid");