tests: avoid false failure in tail inotify test
[coreutils.git] / tests / misc / sort-debug-keys.sh
blobdc02be8b296cfc595e9f75f4d759af27e19f22a7
1 #!/bin/sh
2 # Test annotation of sort keys
4 # Copyright (C) 2010-2016 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 <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ sort printf
22 number() { cat -n | sed 's/^ *//'; }
24 cat <<\EOF > exp
26 ^ no match for key
28 ^ no match for key
30 ^ no match for key
32 ^ no match for key
34 ^ no match for key
36 ^ no match for key
38 ^ no match for key
40 ^ no match for key
42 ^ no match for key
44 ^ no match for key
46 ^ no match for key
56 ^ no match for key
57 3>1
59 1>2
62 ^ no match for key
64 ^ no match for key
66 ^ no match for key
68 ^ no match for key
70 ^ no match for key
72 ^ no match for key
74 ^ no match for key
76 ^ no match for key
78 ^ no match for key
80 ^ no match for key
82 ^ no match for key
92 ^ no match for key
93 3>1
95 1>2
98 ^ no match for key
100 ^ no match for key
102 ^ no match for key
104 ^ no match for key
106 ^ no match for key
108 ^ no match for key
110 ^ no match for key
112 ^ no match for key
114 ^ no match for key
116 ^ no match for key
118 ^ no match for key
128 ^ no match for key
134 ^ no match for key
140 ^ no match for key
142 ^ no match for key
144 ^ no match for key
145 JAZZ
146 ^ no match for key
148 ^ no match for key
153 2>JAZZ
154 ^ no match for key
156 ^ no match for key
157 4>JAN
159 1>FEB
162 ^ no match for key
163 JANZ
170 ^ no match for key
171 2>JANZ
173 4>JAN
175 1>FEB
177 1.2ignore
179 1.1e4ignore
180 _____
186 ^ no match for key
188 ^ no match for key
199 --Mi-1
200 ^ no match for key
223 2.,,3
227 2,,3
237 A>chr10
238 ^ no match for key
239 B>chr1
240 ^ no match for key
248 for type in n h g; do
249 printf '1\n\n44\n33\n2\n' | sort -s -k2$type --debug
250 printf '1\n\n44\n33\n2\n' | sort -s -k1.3$type --debug
251 printf '1\n\n44\n33\n2\n' | sort -s -k1$type --debug
252 printf '2\n\n1\n' | number | sort -s -k2g --debug
253 done
255 printf 'FEB\n\nJAN\n' | sort -s -k1M --debug
256 printf 'FEB\n\nJAN\n' | sort -s -k2,2M --debug
257 printf 'FEB\nJAZZ\n\nJAN\n' | sort -s -k1M --debug
258 printf 'FEB\nJAZZ\n\nJAN\n' | number | sort -s -k2,2M --debug
259 printf 'FEB\nJANZ\n\nJAN\n' | sort -s -k1M --debug
260 printf 'FEB\nJANZ\n\nJAN\n' | number | sort -s -k2,2M --debug
262 printf ' 1.2ignore\n 1.1e4ignore\n' | sort -s -g --debug
264 printf '\tb\n\t\ta\n' | sort -s -d --debug # ignore = 1
266 printf 'a\n\n' | sort -s -k2,2 --debug #lena = 0
268 printf 'b\na\n' | sort -s -k1 --debug #otherwise key compare
270 printf -- '-0\n1\n-2\n--Mi-1\n-3\n-0\n' | sort -s --debug -k1,1h
272 printf ' 1\n1\n' | sort -b --debug
273 printf ' 1\n1\n' | sort -sb --debug
274 printf ' 1\n1\n' | sort --debug
276 # strnumcmp is a bit weird, so we don't match exactly
277 printf '2,5\n2.4\n' | sort -s -k1n --debug
278 printf '2.,,3\n2.4\n' | sort -s -k1n --debug
279 printf '2,,3\n2.4\n' | sort -s -k1n --debug
281 # -z means we convert \0 to \n
282 env printf '1a\x002b\x00' | sort -s -n -z --debug
284 # Check that \0 and \t intermix.
285 printf '\0\ta\n' | sort -s -k2b,2 --debug | tr -d '\0'
287 # Check that key end before key start is not underlined
288 printf 'A\tchr10\nB\tchr1\n' | sort -s -k2.4b,2.3n --debug
290 # Ensure that -b applied before -k offsets
291 printf '1 2\n1 3\n' | sort -s -k1.2b --debug
292 ) > out
294 compare exp out || fail=1
296 cat <<\EOF > exp
297 1²---++3 1,234 Mi
299 _________
300 ________________________
301 1²---++3 1,234 Mi
302 _____
303 ________
304 _______________________
305 +1234 1234Gi 1,234M
306 ^ no match for key
307 _____
308 ^ no match for key
309 ____
310 ____
311 _____
312 _____
313 _____
314 ______
315 ___________________
318 unset LC_ALL
319 f=$LOCALE_FR_UTF8
321 : ${LOCALE_FR_UTF8=none}
322 if test "$LOCALE_FR_UTF8" != "none"; then
324 echo ' 1²---++3 1,234 Mi' |
325 LC_ALL=C sort --debug -k2g -k1b,1
326 echo ' 1²---++3 1,234 Mi' |
327 LC_COLLATE=$f LC_CTYPE=$f LC_NUMERIC=$f LC_MESSAGES=C \
328 sort --debug -k2g -k1b,1
329 echo '+1234 1234Gi 1,234M' |
330 LC_COLLATE=$f LC_CTYPE=$f LC_NUMERIC=$f LC_MESSAGES=C \
331 sort --debug -k1,1n -k1,1g \
332 -k1,1h -k2,2n -k2,2g -k2,2h -k3,3n -k3,3g -k3,3h
333 ) > out
334 compare exp out || fail=1
337 Exit $fail