Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Don't dereference NULL on "jobs -Z" (with no title gi...



details:   https://anonhg.NetBSD.org/src/rev/d9a324da4f4b
branches:  trunk
changeset: 985878:d9a324da4f4b
user:      kre <kre%NetBSD.org@localhost>
date:      Sun Sep 12 01:30:41 2021 +0000

description:
Don't dereference NULL on "jobs -Z" (with no title given), instead
do setproctitle(NULL) (which is not the same thing at all).  Do the
same with jobs -Z '' as setting the title to "sh: " isn't useful.

Improve the way this is documented, and note that it is only done
this way because zsh did it first (ie: pass on the balme, doing this
in the jobs command is simply absurd.)

diffstat:

 bin/sh/jobs.c |   9 ++++++---
 bin/sh/sh.1   |  20 ++++++++++++++++++--
 2 files changed, 24 insertions(+), 5 deletions(-)

diffs (77 lines):

diff -r ebe3939598fb -r d9a324da4f4b bin/sh/jobs.c
--- a/bin/sh/jobs.c     Sat Sep 11 22:34:17 2021 +0000
+++ b/bin/sh/jobs.c     Sun Sep 12 01:30:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: jobs.c,v 1.111 2021/09/11 20:43:32 christos Exp $      */
+/*     $NetBSD: jobs.c,v 1.112 2021/09/12 01:30:41 kre Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)jobs.c     8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: jobs.c,v 1.111 2021/09/11 20:43:32 christos Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.112 2021/09/12 01:30:41 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -564,7 +564,10 @@
                }
 
        if (mode == SHOW_PROCTITLE) {
-               setproctitle("%s", *argptr);
+               if (*argptr && **argptr)
+                       setproctitle("%s", *argptr);
+               else
+                       setproctitle(NULL);
                return 0;
        }
 
diff -r ebe3939598fb -r d9a324da4f4b bin/sh/sh.1
--- a/bin/sh/sh.1       Sat Sep 11 22:34:17 2021 +0000
+++ b/bin/sh/sh.1       Sun Sep 12 01:30:41 2021 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: sh.1,v 1.230 2021/09/11 20:43:32 christos Exp $
+.\"    $NetBSD: sh.1,v 1.231 2021/09/12 01:30:41 kre Exp $
 .\" Copyright (c) 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
@@ -2977,7 +2977,8 @@
 there is no process group leader (should not happen),
 and otherwise exits with status 0.
 .\"
-.It Ic jobs Oo Fl l Ns \&| Ns Fl p \&| Fl Z Oc Op Ar job ...
+.It Ic jobs Oo Fl l Ns \&| Ns Fl p Oc Op Ar job ...
+.It Ic jobs Fl Z Op Ar title
 Without
 .Ar job
 arguments,
@@ -3009,6 +3010,13 @@
 .Fl Z
 flag, the process command line is set using
 .Xr setproctitle 3 .
+If
+.Ar title
+is omitted or a null string,
+.Xr setproctitle 3
+is called with a NULL format.
+.Pp
+These options are mutually exclusive, the last specified is used.
 .Pp
 In an interactive shell, each job shown as completed in the output
 from the jobs command is implicitly waited for, and is removed from
@@ -4736,5 +4744,13 @@
 .Pp
 Job control of compound statements (loops, etc) is a complete mess.
 .Pp
+The
+.Fl Z
+option to the
+.Ic jobs
+built-in command is bizarre, but is implemented this way to be
+compatible with the similar option in
+.Xr zsh 1 .
+.Pp
 Many, many, more.
 (But less than there were...)



Home | Main Index | Thread Index | Old Index