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.
This commit is contained in:
kre 2020-08-30 16:10:40 +00:00
parent 75c5a5daf7
commit 075741c09c
2 changed files with 13 additions and 3 deletions

View File

@ -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 @@ parameter
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

View File

@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994\
#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 @@ printsignals(FILE *fp, int len)
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 @@ printsignals(FILE *fp, int len)
}
pad = (len | 7) + 1 - len;
if (posix && pad)
pad = 1;
for (sig = 0; (sig = signalnext(sig)) != 0; ) {
name = signalname(sig);
@ -297,6 +301,8 @@ printsignals(FILE *fp, int len)
len += nl + pad;
pad = (nl | 7) + 1 - nl;
if (posix && pad)
pad = 1;
fprintf(fp, "%s", name);
}