mirror of
https://github.com/openbsd/src.git
synced 2024-12-22 16:42:56 -08:00
Fix -L/-I processing in -0 mode so that NUL-delimited entries are
treated as "lines". From FreeBSD.
This commit is contained in:
parent
fea506784f
commit
720942423e
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $OpenBSD: xargs-L.sh,v 1.1 2010/03/25 01:43:47 schwarze Exp $
|
||||
# $OpenBSD: xargs-L.sh,v 1.2 2017/01/19 17:08:42 millert Exp $
|
||||
#
|
||||
# written by Ingo Schwarze <schwarze@openbsd.org> 2010
|
||||
# and placed in the public domain
|
||||
@ -76,18 +76,18 @@ test_xargs 'a \\\nb' '-0' 'a \\\nb|'
|
||||
test_xargs 'a\\\n b' '-0' 'a\\\n b|'
|
||||
test_xargs 'a \\\n b' '-0' 'a \\\n b|'
|
||||
|
||||
test_xargs 'a b\0c' '-0 -L 1' 'a b|c|'
|
||||
test_xargs 'a b\0c' '-0 -L 1' 'a b|c|'
|
||||
test_xargs 'a b\0c' '-0 -L 1' 'a b|\nc|'
|
||||
test_xargs 'a b\0c' '-0 -L 1' 'a b|\nc|'
|
||||
test_xargs 'a\nb\0c' '-0 -L 1' 'a\nb|\nc|'
|
||||
test_xargs 'a\n\nb\0c' '-0 -L 1' 'a\n\nb|\nc|'
|
||||
test_xargs 'a \nb\0c' '-0 -L 1' 'a \nb|c|'
|
||||
test_xargs 'a \nb\0c' '-0 -L 1' 'a \nb|\nc|'
|
||||
test_xargs 'a\n b\0c' '-0 -L 1' 'a\n b|\nc|'
|
||||
test_xargs 'a \n b\0c' '-0 -L 1' 'a \n b|c|'
|
||||
test_xargs 'a \n b\0c' '-0 -L 1' 'a \n b|\nc|'
|
||||
test_xargs 'a\n \nb\0c' '-0 -L 1' 'a\n \nb|\nc|'
|
||||
test_xargs 'a \n\nb\0c' '-0 -L 1' 'a \n\nb|c|'
|
||||
test_xargs 'a \n\nb\0c' '-0 -L 1' 'a \n\nb|\nc|'
|
||||
|
||||
test_xargs 'a\\ b\0c' '-0 -L 1' 'a\\ b|c|'
|
||||
test_xargs 'a\\ \nb\0c' '-0 -L 1' 'a\\ \nb|c|'
|
||||
test_xargs 'a\\ b\0c' '-0 -L 1' 'a\\ b|\nc|'
|
||||
test_xargs 'a\\ \nb\0c' '-0 -L 1' 'a\\ \nb|\nc|'
|
||||
test_xargs 'a\n\\ b\0c' '-0 -L 1' 'a\n\\ b|\nc|'
|
||||
|
||||
test_xargs 'a\\\nb\0c' '-0 -L 1' 'a\\\nb|\nc|'
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: xargs.c,v 1.31 2015/12/09 19:29:49 mmcc Exp $ */
|
||||
/* $OpenBSD: xargs.c,v 1.32 2017/01/19 17:08:41 millert Exp $ */
|
||||
/* $FreeBSD: xargs.c,v 1.51 2003/05/03 19:09:11 obrien Exp $ */
|
||||
|
||||
/*-
|
||||
@ -278,15 +278,22 @@ parse_input(int argc, char *argv[])
|
||||
}
|
||||
goto arg1;
|
||||
case '\0':
|
||||
if (zflag)
|
||||
if (zflag) {
|
||||
/*
|
||||
* Increment 'count', so that nulls will be treated
|
||||
* as end-of-line, as well as end-of-argument. This
|
||||
* is needed so -0 works properly with -I and -L.
|
||||
*/
|
||||
count++;
|
||||
goto arg2;
|
||||
}
|
||||
goto addch;
|
||||
case '\n':
|
||||
if (zflag)
|
||||
goto addch;
|
||||
hasblank = 1;
|
||||
if (hadblank == 0)
|
||||
count++;
|
||||
if (zflag)
|
||||
goto addch;
|
||||
|
||||
/* Quotes do not escape newlines. */
|
||||
arg1: if (insingle || indouble)
|
||||
|
Loading…
Reference in New Issue
Block a user