[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: findutils & textutils updates/bug fixes
From: |
Padraig Brady |
Subject: |
Re: findutils & textutils updates/bug fixes |
Date: |
Mon, 18 Jun 2001 13:14:21 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux 2.4.0-ac4 i686; en-US; rv:0.9.1) Gecko/20010607 |
patch for #2 attached.
to apply:
cd findutils-4.1.7; patch -p1 <findutils-4.1.7_xargs.patch
cheers,
Padraig.
Kevin Dalley wrote:
#1 sounds like a good idea.
#2 seems reasonable as well.
I'm not sure about #3 yet. That changes things somewhat. Let me
think about it. I'm trying to fix a number of bugs in findutils, and
have an alpha release available in
ftp://alpha.gnu.org/gnu/findutils-4.1.7.tar.gz
I'll consider adding features in a while.
Thanks for the suggestions.
Padraig Brady <address@hidden> writes:
Hi,
I've a few small patches here which I think are definitely required.
1: findutils
a: find (%D printf specifier added) which prints the device id
associated
with a file. This (in conjunction with the inode number) allows you
to uniquely identify any file on the system, which is
useful/required
for many applications.
b: xargs doesn't ignore "empty" arguments when -0 used (I.E. '\0' is
delimiter).
You can test this like:
address@hidden:~$ echo -ne "1\n\n\n2" | xargs -n1 | od -t x1
0000000 31 0a 32 0a
address@hidden:~$ echo -ne "1\000\000\0002" | xargs -0 -n1 | od
-t x1
0000000 31 0a 0a 0a 32 0a
As you can see the first command works as expected, whereas the
second doesn't.
In summary multiple consequtive '\0's should be squeezed to 1 '\0'
c: Related to b: xargs should have an option to group arguments passed
to commands
by 2 or more delimeters, i.e: you should be able to do:
address@hidden:~$ echo -ne "1\n2\n3\n\na\nb\nc\n" | xargs -nn
1 2 3
a b c
address@hidden:~$
diff -aruN -x *.o findutils-4.1.7/xargs/xargs.1 findutils-pb/xargs/xargs.1
--- findutils-4.1.7/xargs/xargs.1 Sun Feb 4 20:35:11 1996
+++ findutils-pb/xargs/xargs.1 Sat Jun 16 17:02:32 2001
@@ -41,7 +41,8 @@
whitespace, and the quotes and backslash are not special (every
character is taken literally). Disables the end of file string, which
is treated like any other argument. Useful when arguments might
-contain white space, quote marks, or backslashes. The GNU find
+contain white space, quote marks, or backslashes. Redundant null
+characters (initial or adjacent) on the input are ignored. The GNU find
\-print0 option produces input suitable for this mode.
.TP
.I "\-\-eof[=eof-str], \-e[eof-str]"
diff -aruN -x *.o findutils-4.1.7/xargs/xargs.c findutils-pb/xargs/xargs.c
--- findutils-4.1.7/xargs/xargs.c Tue Oct 10 00:40:41 2000
+++ findutils-pb/xargs/xargs.c Sat Jun 16 17:16:52 2001
@@ -563,7 +563,7 @@
}
/* Read a null-terminated string from stdin and add it to the list of
- arguments to pass to the command.
+ arguments to pass to the command. Ignore initial and adjacent NULs.
Return -1 if eof (either physical or logical) is reached,
otherwise the length of the string read (including the null). */
@@ -572,6 +572,7 @@
{
static boolean eof = false;
int len;
+ int pc = '\0';
char *p = linebuf;
/* Including the NUL, the args must not grow past this point. */
char *endbuf = linebuf + arg_max - initial_argv_chars - 1;
@@ -594,7 +595,9 @@
}
if (c == '\0')
{
- lineno++; /* For -l. */
+ if (pc == '\0')
+ continue; /* skip redundant NULs */
+ lineno++; /* For -l. */
*p++ = '\0';
len = p - linebuf;
if (!replace_pat)
@@ -604,6 +607,7 @@
if (p >= endbuf)
error (1, 0, _("argument line too long"));
*p++ = c;
+ pc = c;
}
}
diff -aruN -x *.o findutils-4.1.7/xargs/testsuite/inputs/files00.xi
findutils-pb/xargs/testsuite/inputs/files00.xi
--- findutils-4.1.7/xargs/testsuite/inputs/files00.xi Thu Jan 1 01:00:00 1970
+++ findutils-pb/xargs/testsuite/inputs/files00.xi Sat Jun 16 19:18:24 2001
@@ -0,0 +1 @@
+ /src/gnu/autoconf-1.11 /src/gnu/autoconf-1.11/README /src/gnu/autoconf-1.11/Makefile.in
\ No newline at end of file
diff -aruN -x *.o findutils-4.1.7/xargs/testsuite/xargs.gnu/redundant0.exp
findutils-pb/xargs/testsuite/xargs.gnu/redundant0.exp
--- findutils-4.1.7/xargs/testsuite/xargs.gnu/redundant0.exp Thu Jan 1
01:00:00 1970
+++ findutils-pb/xargs/testsuite/xargs.gnu/redundant0.exp Sat Jun 16
18:57:14 2001
@@ -0,0 +1 @@
+xargs_start p {-0} files00.xi
diff -aruN -x *.o findutils-4.1.7/xargs/testsuite/xargs.gnu/redundant0.xo
findutils-pb/xargs/testsuite/xargs.gnu/redundant0.xo
--- findutils-4.1.7/xargs/testsuite/xargs.gnu/redundant0.xo Thu Jan 1
01:00:00 1970
+++ findutils-pb/xargs/testsuite/xargs.gnu/redundant0.xo Sat Jun 16
19:18:49 2001
@@ -0,0 +1 @@
+/src/gnu/autoconf-1.11 /src/gnu/autoconf-1.11/README
/src/gnu/autoconf-1.11/Makefile.in