join: fix error message for -a and -v
[coreutils.git] / tests / split / numeric.sh
blob6bce3248286be2766db9fa7ff66a58b43422df24
1 #!/bin/sh
2 # Test --{hex,numeric}-suffixes[=from]
4 # Copyright (C) 2012-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ split
22 printf '1\n2\n3\n4\n5\n' > in || framework_failure_
24 printf '%s\n' 1 2 > exp-0 || framework_failure_
25 printf '%s\n' 3 4 > exp-1 || framework_failure_
26 printf '%s\n' 5 > exp-2 || framework_failure_
28 for mode in 'numeric' 'hex'; do
30 for start in 0 9; do
31 mode_option="--$mode-suffixes"
32 # check with and without specified start value
33 test $start != '0' && mode_option="$mode_option=$start"
34 split $mode_option --lines=2 in || fail=1
36 test $mode = 'hex' && format=x || format=d
37 for i in $(seq $start $(($start+2))); do
38 compare exp-$(($i-$start)) x$(printf %02$format $i) || fail=1
39 done
40 done
42 # Check that split failed when suffix length is not large enough for
43 # the numerical suffix start value
44 returns_ 1 split -a 3 --$mode-suffixes=1000 in 2>/dev/null || fail=1
46 # check invalid --$mode-suffixes start values are flagged
47 returns_ 1 split --$mode-suffixes=-1 in 2> /dev/null || fail=1
48 returns_ 1 split --$mode-suffixes=one in 2> /dev/null || fail=1
49 done
51 Exit $fail