[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Splitting search results from a "find -print0"
From: |
Pádraig Brady |
Subject: |
Re: Splitting search results from a "find -print0" |
Date: |
Sat, 10 Jan 2015 18:24:56 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
On 10/01/15 16:58, Bernhard Voelker wrote:
> On 01/09/2015 01:29 PM, Pádraig Brady wrote:
>> --- /dev/null
>> +++ b/tests/split/lines-sep.sh
>> @@ -0,0 +1,78 @@
>> +#!/bin/sh
>> +# test split with custom record separators
>> +
>> +# Copyright (C) 2015 Free Software Foundation, Inc.
>> +
>> +# This program is free software: you can redistribute it and/or modify
>> +# it under the terms of the GNU General Public License as published by
>> +# the Free Software Foundation, either version 3 of the License, or
>> +# (at your option) any later version.
>> +
>> +# This program is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> +# GNU General Public License for more details.
>> +
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
>> +
>> +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
>> +print_ver_ split
>> +
>> +NL='
>> +'
>> +
>> +for sep in "$NL" '\0' ':'; do
>> +
>> + test "$sep" = "$NL" && tr='\n' || tr="$sep"
>> +
>> + for mode in '--lines=2' '--line-bytes=4' '--number=l/3' '--number=r/3'; do
>> +
>> + # Generate in default mode for comparison
>> + printf '1\n2\n3\n4\n5\n' > in || framework_failure_
>> + split $mode in || return 1
>> + tr '\n' "$tr" < xaa > exp1
>> + tr '\n' "$tr" < xab > exp2
>> + tr '\n' "$tr" < xac > exp3
>> +
>> + rm -f x??
>> +
>> + # Generate output with specified --separator
>> + printf '1\n2\n3\n4\n5\n' | tr '\n' "$tr" > in || framework_failure_
>> + split $mode -t "$sep" in || return 1
>> +
>> + compare exp1 xaa || return 1
>> + compare exp2 xab || return 1
>> + compare exp3 xac || return 1
>> + test -f xad && return 1
>
> s/return 1/fail=1/
Heh I caught that myself :)
> ...interestingly, such syntax failure wouldn't have shown up in the test
> result:
>
> + return 1
> ./tests/split/lines-sep.sh: line ??: return: can only `return' from a
> function or sourced script
Yep, I think only `set -e` would catch that, but adding that
to setup_() in tests/init.sh give lots of failures:
============================================================================
Testsuite summary for GNU coreutils 8.23.95-8c819
============================================================================
# TOTAL: 572
# PASS: 376
# SKIP: 101
# XFAIL: 0
# FAIL: 95
# XPASS: 0
# ERROR: 0
Something to consider enabling shen developing new tests at least.
> Otherwise +1, Nice work!
> ... last question: shouldn't "split --bytes=123 --separator=X"
> return an error like "uncompatible options"?
I did think about that. They're not incompatible, just that --separator
is ignored in that case. There are many undiagnosed cases of that,
and some with warnings issued:
$ git grep error.*ignored
src/install.c: error (0, 0, _("the --compare (-C) option is ignored when you"
src/numfmt.c: error (0, 0, _("--header ignored with command-line
input"));
src/sort.c: error (0, 0, _("key %lu has zero width and will be
ignored"), keynum);
src/tail.c: error (0, 0, _("warning: --retry ignored; --retry is
useful"
I didn't think a warning was warranted in this case.
Something to consider if we add --debug to more utils.
thanks,
Pádraig.
- Re: Splitting search results from a "find -print0", (continued)
- Re: Splitting search results from a "find -print0", Pádraig Brady, 2015/01/08
- Re: Splitting search results from a "find -print0", Assaf Gordon, 2015/01/08
- Re: Splitting search results from a "find -print0", Pádraig Brady, 2015/01/08
- RE: Splitting search results from a "find -print0", Cook, Malcolm, 2015/01/09
- Re: Splitting search results from a "find -print0", Bernhard Voelker, 2015/01/09
- Re: Splitting search results from a "find -print0", Pádraig Brady, 2015/01/09
- Re: Splitting search results from a "find -print0", Bernhard Voelker, 2015/01/10
- Re: Splitting search results from a "find -print0",
Pádraig Brady <=
- Re: Splitting search results from a "find -print0", Bernhard Voelker, 2015/01/10
Re: Splitting search results from a "find -print0", Markus Elfring, 2015/01/09