diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2020-07-19 13:19:26 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2020-07-19 13:19:26 +0000 |
commit | c8c138d83f0e15ed6531ab7c7bb7044850d979c1 (patch) | |
tree | 492b9e86f50ff1d4110d42af155130d64c76ed5f /usr.bin/xargs | |
parent | 8fb469cede9643d81a2972501d0eddd0a3926cdf (diff) |
Delete support for LC_MESSAGES which we shall never implement.
This nicely simplifies the code, deleting three header inclusions
and calls to various complicated library functions.
Dead code reported by Jan Stary <hans at stare dot cz>.
Garbage collect pointless (void) casts and a .Tn macro while here.
Tweaks and OK martijn@, OK millert@ and kn@ on an earlier version.
Diffstat (limited to 'usr.bin/xargs')
-rw-r--r-- | usr.bin/xargs/xargs.1 | 15 | ||||
-rw-r--r-- | usr.bin/xargs/xargs.c | 36 |
2 files changed, 19 insertions, 32 deletions
diff --git a/usr.bin/xargs/xargs.1 b/usr.bin/xargs/xargs.1 index 68826a528d2..040f4f5c643 100644 --- a/usr.bin/xargs/xargs.1 +++ b/usr.bin/xargs/xargs.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: xargs.1,v 1.28 2014/06/04 06:48:33 jmc Exp $ +.\" $OpenBSD: xargs.1,v 1.29 2020/07/19 13:19:25 schwarze Exp $ .\" $FreeBSD: xargs.1,v 1.30 2003/05/21 21:07:28 ru Exp $$ .\" .\" Copyright (c) 1990, 1991, 1993 @@ -34,7 +34,7 @@ .\" .\" @(#)xargs.1 8.1 (Berkeley) 6/6/93 .\" -.Dd $Mdocdate: June 4 2014 $ +.Dd $Mdocdate: July 19 2020 $ .Dt XARGS 1 .Os .Sh NAME @@ -213,11 +213,11 @@ at once. .It Fl p Echo each command to be executed and ask the user whether it should be executed. -An affirmative response, +If the answer starts with .Ql y -in the POSIX locale, -causes the command to be executed, any other response causes it to be -skipped. +or +.Ql Y , +the command is executed; otherwise it is skipped. No commands are executed if the process is not attached to a terminal. .It Fl R Ar replacements Specify the maximum number of arguments that @@ -330,8 +330,7 @@ The flags are extensions to .St -p1003.1-2008 . .Pp -The meanings of the 123, 124, and 125 exit values were taken from -.Tn GNU +The meanings of the 123, 124, and 125 exit values were taken from GNU .Nm xargs . .Sh HISTORY The diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index ce1533e7016..a7c5c89988b 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xargs.c,v 1.34 2018/06/12 15:24:31 millert Exp $ */ +/* $OpenBSD: xargs.c,v 1.35 2020/07/19 13:19:25 schwarze Exp $ */ /* $FreeBSD: xargs.c,v 1.51 2003/05/03 19:09:11 obrien Exp $ */ /*- @@ -41,10 +41,7 @@ #include <err.h> #include <errno.h> #include <fcntl.h> -#include <langinfo.h> -#include <locale.h> #include <paths.h> -#include <regex.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -86,8 +83,6 @@ main(int argc, char *argv[]) eofstr = ""; Jflag = nflag = 0; - (void)setlocale(LC_MESSAGES, ""); - /* * POSIX.2 limits the exec line length to ARG_MAX - 2K. Running that * caused some E2BIG errors, so it was changed to ARG_MAX - 4K. Given @@ -507,9 +502,9 @@ run(char **argv) * followed by a prompt, then prompt them. */ if (tflag || pflag) { - (void)fprintf(stderr, "%s", *argv); + fprintf(stderr, "%s", *argv); for (avec = argv + 1; *avec != NULL; ++avec) - (void)fprintf(stderr, " %s", *avec); + fprintf(stderr, " %s", *avec); /* * If the user has asked to be prompted, do so. */ @@ -528,8 +523,8 @@ run(char **argv) case 2: break; } - (void)fprintf(stderr, "\n"); - (void)fflush(stderr); + fprintf(stderr, "\n"); + fflush(stderr); } exec: switch (pid = vfork()) { @@ -607,26 +602,19 @@ waitchildren(const char *name, int waitall) static int prompt(void) { - regex_t cre; size_t rsize; - int match; char *response; FILE *ttyfp; + int doit = 0; if ((ttyfp = fopen(_PATH_TTY, "r")) == NULL) return (2); /* Indicate that the TTY failed to open. */ - (void)fprintf(stderr, "?..."); - (void)fflush(stderr); - if ((response = fgetln(ttyfp, &rsize)) == NULL || - regcomp(&cre, nl_langinfo(YESEXPR), REG_BASIC) != 0) { - (void)fclose(ttyfp); - return (0); - } - response[rsize - 1] = '\0'; - match = regexec(&cre, response, 0, NULL, 0); - (void)fclose(ttyfp); - regfree(&cre); - return (match == 0); + fprintf(stderr, "?..."); + fflush(stderr); + response = fgetln(ttyfp, &rsize); + doit = response != NULL && (*response == 'y' || *response == 'Y'); + fclose(ttyfp); + return (doit); } static void |