diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-05-06 01:48:40 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-05-13 12:43:40 +0100 |
commit | 703747f892d3ec4713b97d4bff770a80122cd1ef (patch) | |
tree | 97caf65ccdb43c5f01785ade78dbaf29c3cfc9ae /tests/split | |
parent | 79111d1553ff6603199b9e8e5f27269d55b095fb (diff) | |
download | coreutils-703747f892d3ec4713b97d4bff770a80122cd1ef.tar.xz |
split: auto set suffix len for --numeric-suffixes=<N --number=N
Supporting `split --numeric-suffixes=1 -n100` for example.
* doc/coreutils.texi (split invocation): Mention the two
use cases for the FROM parameter, and the consequences on
the suffix length determination.
* src/split.c (set_suffix_length): Use the --numeric-suffixes
FROM parameter in the suffix width calculation, when it's
less than the number of files specified in --number.
* tests/split/suffix-auto-length.sh: Add test cases.
Fixes http://bugs.gnu.org/20511
Diffstat (limited to 'tests/split')
-rwxr-xr-x | tests/split/suffix-auto-length.sh | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/split/suffix-auto-length.sh b/tests/split/suffix-auto-length.sh index 6ee220066..6ef221a16 100755 --- a/tests/split/suffix-auto-length.sh +++ b/tests/split/suffix-auto-length.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Test the suffix auto widening functionality +# Test the suffix auto width functionality # Copyright (C) 2012-2015 Free Software Foundation, Inc. @@ -20,14 +20,14 @@ print_ver_ split -# ensure this feature is off when start number specified -truncate -s12 file.in +# ensure auto widening is off when start number specified +truncate -s12 file.in || framework_failure_ returns_ 1 split file.in -b1 --numeric=89 || fail=1 test "$(ls -1 x* | wc -l)" = 11 || fail=1 rm -f x* -# ensure this feature works when no start num specified -truncate -s91 file.in +# ensure auto widening works when no start num specified +truncate -s91 file.in || framework_failure_ for prefix in 'x' 'xx' ''; do for add_suffix in '.txt' ''; do split file.in "$prefix" -b1 --numeric --additional-suffix="$add_suffix" \ @@ -39,4 +39,15 @@ for prefix in 'x' 'xx' ''; do done done +# ensure auto width with --number and start num < number of files +# That's the single run use case which is valid to adjust suffix len +truncate -s100 file.in || framework_failure_ +split --numeric-suffixes=1 --number=r/100 file.in || fail=1 +rm -f x* + +# ensure no auto width with --number and start num >= number of files +# That's the multi run use case which is invalid to adjust suffix len +# as that would result in an incorrect order for the total output file set +returns_ 1 split --numeric-suffixes=100 --number=r/100 file.in || fail=1 + Exit $fail |