Date: Thu, 1 Sep 2005 11:49:33 +0200 From: Stefan Bethke <stb@lassitu.de> To: freebsd-standards@freebsd.org Subject: xargs </dev/null behaviour Message-ID: <E02AB45B-DC18-4FBB-A9E2-3A3E1C856A16@lassitu.de>
next in thread | raw e-mail | index | archive | help
I've stumbled over the differing behavior of xargs when standard input delivers an immediate end of file: In recent versions of FreeBSD and OpenBSD, I get this: $ xargs echo foo </dev/null $ On Solaris and Linux, I get this: $ xargs echo foo </dev/null foo $ Carefully reading the SUSv3 man page (the Solaris 10 one has very similar wordage), the Solaris/Linux behaviour seems to be correct: > The xargs utility shall construct a command line consisting of the > utility and argument operands specified followed by as many > arguments read in sequence from standard input as fit in length and > number constraints specified by the options. The xargs utility > shall then invoke the constructed command line and wait for its > completion. This sequence shall be repeated [...] I personally prefer the BSD behaviour, but I wonder whether anyone might rely on the SUSv3 behavior? I came across a makefile that assumed BSD behavior, but failed: find . -name "*.orig" | xargs rm because no orig files were found, but rm was executed anyway, with zero arguments. Stefan -- Stefan Bethke <stb@lassitu.de> Fon +49 170 346 0140
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E02AB45B-DC18-4FBB-A9E2-3A3E1C856A16>