xargs article: add some notes for portability and historic context - www.codemadness.org - www.codemadness.org saait content files
(HTM) git clone git://git.codemadness.org/www.codemadness.org
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 48acce4b0ec634fc893b61589bd755069a70f25f
(DIR) parent 7f6beb4e5733154d4067672b4a0d0e4e51e23fd2
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 17 Dec 2023 12:34:39 +0100
xargs article: add some notes for portability and historic context
Diffstat:
M config.cfg | 2 +-
M output/atom.xml | 4 ++--
M output/atom_content.xml | 53 ++++++++++++++++++++++++++-----
M output/rss_content.xml | 49 +++++++++++++++++++++++++++----
M output/sitemap.xml | 2 +-
M output/xargs.html | 49 +++++++++++++++++++++++++++----
M output/xargs.md | 65 +++++++++++++++++++++++++++----
M pages/xargs.cfg | 2 +-
M pages/xargs.md | 65 +++++++++++++++++++++++++++----
9 files changed, 252 insertions(+), 39 deletions(-)
---
(DIR) diff --git a/config.cfg b/config.cfg
@@ -1,5 +1,5 @@
# last updated the site.
-siteupdated = 2023-11-22
+siteupdated = 2023-12-17
sitetitle = Codemadness
siteurl = https://www.codemadness.org
(DIR) diff --git a/output/atom.xml b/output/atom.xml
@@ -2,7 +2,7 @@
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title>Codemadness</title>
<subtitle>blog with various projects and articles about computer-related things</subtitle>
- <updated>2023-11-22T00:00:00Z</updated>
+ <updated>2023-12-17T00:00:00Z</updated>
<link rel="alternate" type="text/html" href="https://www.codemadness.org" />
<id>https://www.codemadness.org/atom.xml</id>
<link rel="self" type="application/atom+xml" href="https://www.codemadness.org/atom.xml" />
@@ -10,7 +10,7 @@
<title>xargs: an example for parallel batch jobs</title>
<link rel="alternate" type="text/html" href="https://www.codemadness.org/xargs.html" />
<id>https://www.codemadness.org/xargs.html</id>
- <updated>2023-11-23T00:00:00Z</updated>
+ <updated>2023-12-17T00:00:00Z</updated>
<published>2023-11-22T00:00:00Z</published>
<author>
<name>Hiltjo</name>
(DIR) diff --git a/output/atom_content.xml b/output/atom_content.xml
@@ -2,7 +2,7 @@
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title>Codemadness</title>
<subtitle>blog with various projects and articles about computer-related things</subtitle>
- <updated>2023-11-22T00:00:00Z</updated>
+ <updated>2023-12-17T00:00:00Z</updated>
<link rel="alternate" type="text/html" href="https://www.codemadness.org" />
<id>https://www.codemadness.org/atom_content.xml</id>
<link rel="self" type="application/atom+xml" href="https://www.codemadness.org/atom_content.xml" />
@@ -10,7 +10,7 @@
<title>xargs: an example for parallel batch jobs</title>
<link rel="alternate" type="text/html" href="https://www.codemadness.org/xargs.html" />
<id>https://www.codemadness.org/xargs.html</id>
- <updated>2023-11-23T00:00:00Z</updated>
+ <updated>2023-12-17T00:00:00Z</updated>
<published>2023-11-22T00:00:00Z</published>
<author>
<name>Hiltjo</name>
@@ -18,7 +18,7 @@
</author>
<summary>xargs: an example for parallel batch jobs</summary>
<content type="html"><
+
+On OpenBSD the xargs -P option was added on 2003-12-06 by syncing the FreeBSD
+code:
+
+[CVS log](http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/xargs/xargs.c?rev=1.14&content-type=text/x-cvsweb-markup)
+
+
+Looking at the imported git history log of GNU findutils (which has xargs), the
+very first commit already had the -0 and -P option:
+
+[git log](https://savannah.gnu.org/git/?group=findutils)
+
+ commit c030b5ee33bbec3c93cddc3ca9ebec14c24dbe07
+ Author: Kevin Dalley <kevin@seti.org>
+ Date: Sun Feb 4 20:35:16 1996 +0000
+
+ Initial revision
+
+
+# xargs: some incompatibilities found
+
+* Using the -0 option empty fields are handled differently in different
+ implementations.
+* The -n and -L option doesn't work correctly in many of the BSD implementations.
+ Some count empty fields, some don't. In early implementations in FreeBSD and
+ OpenBSD it only processed the first line. In OpenBSD it has been improved
+ around 2017.
+
+Depending on what you want to do a workaround could be to use the -0 option
+with a single field and use the -n flag. Then in each child program invocation
+split the field by a separator.
+
+
# References
* xargs: <https://man.openbsd.org/xargs>
(DIR) diff --git a/pages/xargs.cfg b/pages/xargs.cfg
@@ -3,4 +3,4 @@ id = xargs
description = xargs: an example for parallel batch jobs
keywords = xargs, wow hyper speed
created = 2023-11-22
-updated = 2023-11-23
+updated = 2023-12-17
(DIR) diff --git a/pages/xargs.md b/pages/xargs.md
@@ -154,14 +154,8 @@ The child process:
xargs stops running also.
-# xargs -P and portability
-Note that some of the options, like -P are as of writing (2023) non-POSIX:
-<https://pubs.opengroup.org/onlinepubs/9699919799/>.
-However many systems support this useful extension.
-
-
-# Explanation of used xargs options:
+# Description of used xargs options
From the OpenBSD man page: <https://man.openbsd.org/xargs>
@@ -181,6 +175,63 @@ Options explained:
been read then utility will be called with the available lines.
+# xargs options -0 and -P, portability and historic context
+
+Some of the options, like -P are as of writing (2023) non-POSIX:
+<https://pubs.opengroup.org/onlinepubs/9699919799/utilities/xargs.html>.
+However many systems support this useful extension for many years now.
+
+The specification even mentions implementations which support parallel
+operations:
+
+"The version of xargs required by this volume of POSIX.1-2017 is required to
+wait for the completion of the invoked command before invoking another command.
+This was done because historical scripts using xargs assumed sequential
+execution. Implementations wanting to provide parallel operation of the invoked
+utilities are encouraged to add an option enabling parallel invocation, but
+should still wait for termination of all of the children before xargs
+terminates normally."
+
+
+Some historic context:
+
+The xargs -0 option was added on 1996-06-11 by Theo de Raadt, about a year
+after the NetBSD import (over 27 years ago at the time of writing):
+
+[CVS log](http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/xargs/xargs.c?rev=1.2&content-type=text/x-cvsweb-markup)
+
+On OpenBSD the xargs -P option was added on 2003-12-06 by syncing the FreeBSD
+code:
+
+[CVS log](http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/xargs/xargs.c?rev=1.14&content-type=text/x-cvsweb-markup)
+
+
+Looking at the imported git history log of GNU findutils (which has xargs), the
+very first commit already had the -0 and -P option:
+
+[git log](https://savannah.gnu.org/git/?group=findutils)
+
+ commit c030b5ee33bbec3c93cddc3ca9ebec14c24dbe07
+ Author: Kevin Dalley <kevin@seti.org>
+ Date: Sun Feb 4 20:35:16 1996 +0000
+
+ Initial revision
+
+
+# xargs: some incompatibilities found
+
+* Using the -0 option empty fields are handled differently in different
+ implementations.
+* The -n and -L option doesn't work correctly in many of the BSD implementations.
+ Some count empty fields, some don't. In early implementations in FreeBSD and
+ OpenBSD it only processed the first line. In OpenBSD it has been improved
+ around 2017.
+
+Depending on what you want to do a workaround could be to use the -0 option
+with a single field and use the -n flag. Then in each child program invocation
+split the field by a separator.
+
+
# References
* xargs: <https://man.openbsd.org/xargs>