ls: tune is_colored
[coreutils.git] / tests / sort / sort-compress.sh
blobaf309142e190f0fb63e80f6acd957fbf11663ead
1 #!/bin/sh
2 # Test use of compression by sort
4 # Copyright (C) 2007-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_ sort
21 require_trap_signame_
23 seq -w 2000 > exp || framework_failure_
24 tac exp > in || framework_failure_
26 # This should force the use of temp files
27 sort -S 1k in > out || fail=1
28 compare exp out || fail=1
30 # Create our own gzip program that will be used as the default
31 cat <<EOF > gzip || framework_failure_
32 #!$SHELL
33 tr 41 14
34 touch ok
35 EOF
37 chmod +x gzip
39 # Ensure 'sort' is immune to parent's SIGCHLD handler
40 # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
42 trap '' CHLD
44 # This should force the use of child processes for "compression"
45 PATH=.:$PATH exec sort -S 1k --compress-program=gzip in > /dev/null
46 ) || fail=1
48 # This will find our new gzip in PATH
49 PATH=.:$PATH sort -S 1k --compress-program=gzip in > out || fail=1
50 compare exp out || fail=1
51 test -f ok || fail=1
52 rm -f ok
54 # This is to make sure it works with no compression.
55 PATH=.:$PATH sort -S 1k in > out || fail=1
56 compare exp out || fail=1
57 test -f ok && fail=1
59 # This is to make sure we can use something other than gzip
60 mv gzip dzip || fail=1
61 sort --compress-program=./dzip -S 1k in > out || fail=1
62 compare exp out || fail=1
63 test -f ok || fail=1
64 rm -f ok
66 # Make sure it can find other programs in PATH correctly
67 PATH=.:$PATH sort --compress-program=dzip -S 1k in > out || fail=1
68 compare exp out || fail=1
69 test -f ok || fail=1
70 rm -f dzip ok
72 Exit $fail