From owner-svn-src-all@freebsd.org Wed Sep 30 00:53:56 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C87B03F6641; Wed, 30 Sep 2020 00:53:56 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C1Hnc4sWbz4V96; Wed, 30 Sep 2020 00:53:56 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8AD6B176F0; Wed, 30 Sep 2020 00:53:56 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08U0ru8i045213; Wed, 30 Sep 2020 00:53:56 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08U0ruja045211; Wed, 30 Sep 2020 00:53:56 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202009300053.08U0ruja045211@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 30 Sep 2020 00:53:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r366276 - stable/12/usr.bin/xargs X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/usr.bin/xargs X-SVN-Commit-Revision: 366276 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Sep 2020 00:53:56 -0000 Author: kevans Date: Wed Sep 30 00:53:55 2020 New Revision: 366276 URL: https://svnweb.freebsd.org/changeset/base/366276 Log: MFC r365954: xargs: add some long options for GNU compatibility These are low-effort to add, so let's just do it. Modified: stable/12/usr.bin/xargs/xargs.1 stable/12/usr.bin/xargs/xargs.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/xargs/xargs.1 ============================================================================== --- stable/12/usr.bin/xargs/xargs.1 Wed Sep 30 00:47:57 2020 (r366275) +++ stable/12/usr.bin/xargs/xargs.1 Wed Sep 30 00:53:55 2020 (r366276) @@ -33,7 +33,7 @@ .\" $FreeBSD$ .\" $xMach: xargs.1,v 1.2 2002/02/23 05:23:37 tim Exp $ .\" -.Dd August 4, 2015 +.Dd September 29, 2020 .Dt XARGS 1 .Os .Sh NAME @@ -84,7 +84,7 @@ Any single character, including newlines, may be escap .Pp The options are as follows: .Bl -tag -width indent -.It Fl 0 +.It Fl 0 , Fl -null Change .Nm to expect NUL @@ -175,7 +175,7 @@ If EOF is reached and fewer lines have been read than then .Ar utility will be called with the available lines. -.It Fl n Ar number +.It Fl n Ar number , Fl -max-args= Ns Ar number Set the maximum number of arguments taken from standard input for each invocation of .Ar utility . @@ -201,7 +201,7 @@ in the child process before executing the command. This is useful if you want .Nm to run an interactive application. -.It Fl P Ar maxprocs +.It Fl P Ar maxprocs , Fl -max-procs= Ns Ar maxprocs Parallel mode: run at most .Ar maxprocs invocations of @@ -212,7 +212,7 @@ If is set to 0, .Nm will run as many processes as possible. -.It Fl p +.It Fl p , Fl -interactive Echo each command to be executed and ask the user whether it should be executed. An affirmative response, @@ -221,7 +221,7 @@ in the POSIX locale, causes the command to be executed, any other response causes it to be skipped. No commands are executed if the process is not attached to a terminal. -.It Fl r +.It Fl r , Fl -no-run-if-empty Compatibility with GNU .Nm . The GNU version of @@ -263,7 +263,7 @@ can use for replacements. The default for .Ar replsize is 255. -.It Fl s Ar size +.It Fl s Ar size , Fl -max-chars= Ns Ar size Set the maximum number of bytes for the command line length provided to .Ar utility . The sum of the length of the utility name, the arguments passed to @@ -277,10 +277,10 @@ The current default value for is .Dv ARG_MAX - 4096. -.It Fl t +.It Fl t , Fl -verbose Echo the command to be executed to standard error immediately before it is executed. -.It Fl x +.It Fl x , Fl -exit Force .Nm to terminate immediately if a command line containing Modified: stable/12/usr.bin/xargs/xargs.c ============================================================================== --- stable/12/usr.bin/xargs/xargs.c Wed Sep 30 00:47:57 2020 (r366275) +++ stable/12/usr.bin/xargs/xargs.c Wed Sep 30 00:53:55 2020 (r366276) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -98,6 +99,22 @@ static volatile int childerr; extern char **environ; +static const char *optstr = "+0E:I:J:L:n:oP:pR:S:s:rtx"; + +static const struct option long_options[] = +{ + {"exit", no_argument, NULL, 'x'}, + {"interactive", no_argument, NULL, 'p'}, + {"max-args", required_argument, NULL, 'n'}, + {"max-chars", required_argument, NULL, 's'}, + {"max-procs", required_argument, NULL, 'P'}, + {"no-run-if-empty", no_argument, NULL, 'r'}, + {"null", no_argument, NULL, '0'}, + {"verbose", no_argument, NULL, 't'}, + + {NULL, no_argument, NULL, 0}, +}; + int main(int argc, char *argv[]) { @@ -137,7 +154,7 @@ main(int argc, char *argv[]) nline -= strlen(*ep++) + 1 + sizeof(*ep); } maxprocs = 1; - while ((ch = getopt(argc, argv, "0E:I:J:L:n:oP:pR:S:s:rtx")) != -1) + while ((ch = getopt_long(argc, argv, optstr, long_options, NULL)) != -1) switch (ch) { case 'E': eofstr = optarg;