Source-Changes-HG archive

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

[src/trunk]: src/bin/kill Use the POSIX specified format if POSIXLY_CORRECT i...



details:   https://anonhg.NetBSD.org/src/rev/404370949877
branches:  trunk
changeset: 938009:404370949877
user:      kre <kre%NetBSD.org@localhost>
date:      Sun Aug 30 16:10:40 2020 +0000

description:
Use the POSIX specified format if POSIXLY_CORRECT is set in the
environment, rather than the nicer layout that is normally used.

Note this applies to /bin/kill only, the builtin kill in sh uses its
"posix" option for the same purpose, the one in csh only ever uses
POSIX format.

diffstat:

 bin/kill/kill.1 |   6 +++++-
 bin/kill/kill.c |  10 ++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diffs (66 lines):

diff -r c7be5bdacd64 -r 404370949877 bin/kill/kill.1
--- a/bin/kill/kill.1   Sun Aug 30 14:25:45 2020 +0000
+++ b/bin/kill/kill.1   Sun Aug 30 16:10:40 2020 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: kill.1,v 1.30 2020/05/06 13:13:50 kre Exp $
+.\"    $NetBSD: kill.1,v 1.31 2020/08/30 16:10:40 kre Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -81,6 +81,10 @@
 or a signal number.
 .Pp
 If no operand is given, display the names of all the signals.
+In /bin/kill, if the variable
+.Dv POSIXLY_CORRECT
+is set in the environment, this uses the POSIX specified format,
+otherwise a slightly more pleasing layout is used.
 .It Fl signal_name
 A symbolic signal name specifying the signal to be sent instead of the
 default
diff -r c7be5bdacd64 -r 404370949877 bin/kill/kill.c
--- a/bin/kill/kill.c   Sun Aug 30 14:25:45 2020 +0000
+++ b/bin/kill/kill.c   Sun Aug 30 16:10:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kill.c,v 1.30 2018/12/12 20:22:43 kre Exp $ */
+/* $NetBSD: kill.c,v 1.31 2020/08/30 16:10:40 kre Exp $ */
 
 /*
  * Copyright (c) 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)kill.c     8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: kill.c,v 1.30 2018/12/12 20:22:43 kre Exp $");
+__RCSID("$NetBSD: kill.c,v 1.31 2020/08/30 16:10:40 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -267,7 +267,9 @@
        int nl, pad;
        const char *name;
        int termwidth = 80;
+       int posix;
 
+       posix = getenv("POSIXLY_CORRECT") != 0;
        if ((name = getenv("COLUMNS")) != 0)
                termwidth = atoi(name);
        else if (isatty(fileno(fp))) {
@@ -278,6 +280,8 @@
        }
 
        pad = (len | 7) + 1 - len;
+       if (posix && pad)
+               pad = 1;
 
        for (sig = 0; (sig = signalnext(sig)) != 0; ) {
                name = signalname(sig);
@@ -297,6 +301,8 @@
 
                len += nl + pad;
                pad = (nl | 7) + 1 - nl;
+               if (posix && pad)
+                       pad = 1;
 
                fprintf(fp, "%s", name);
        }



Home | Main Index | Thread Index | Old Index