2 # Test annotation of sort keys
4 # Copyright (C) 2010 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 if test "$VERBOSE" = yes; then
26 number
() { cat -n |
sed 's/^ *//'; }
242 for type in n h g
; do
243 printf "1\n\n44\n33\n2\n" |
sort -s -k2$type --debug
244 printf "1\n\n44\n33\n2\n" |
sort -s -k1.3
$type --debug
245 printf "1\n\n44\n33\n2\n" |
sort -s -k1$type --debug
246 printf "2\n\n1\n" | number |
sort -s -k2g --debug
249 printf "FEB\n\nJAN\n" |
sort -s -k1M --debug
250 printf "FEB\n\nJAN\n" |
sort -s -k2,2M
--debug
251 printf "FEB\nJAZZ\n\nJAN\n" |
sort -s -k1M --debug
252 printf "FEB\nJAZZ\n\nJAN\n" | number |
sort -s -k2,2M
--debug
253 printf "FEB\nJANZ\n\nJAN\n" |
sort -s -k1M --debug
254 printf "FEB\nJANZ\n\nJAN\n" | number |
sort -s -k2,2M
--debug
256 printf " 1.2ignore\n 1.1e4ignore\n" |
sort -s -g --debug
258 printf "\tb\n\t\ta\n" |
sort -s -d --debug # ignore = 1
260 printf "a\n\n" |
sort -s -k2,2 --debug #lena = 0
262 printf "b\na\n" |
sort -s -k1 --debug #otherwise key compare
264 printf -- "-0\n1\n-2\n--Mi-1\n-3\n-0\n" |
sort -s --debug -k1,1h
266 printf " 1\n1\n" |
sort -b --debug
267 printf " 1\n1\n" |
sort -sb --debug
268 printf " 1\n1\n" |
sort --debug
270 # strnumcmp is a bit weird, so we don't match exactly
271 printf "2,5\n2.4\n" |
sort -s -k1n --debug
272 printf "2.,,3\n2.4\n" |
sort -s -k1n --debug
273 printf "2,,3\n2.4\n" |
sort -s -k1n --debug
275 # -z means we convert \0 to \n
276 printf "1a\x002b\x00" |
sort -s -n -z --debug
279 compare out exp || fail
=1
285 ________________________
289 _______________________
303 : ${LOCALE_FR_UTF8=none}
304 if test "$LOCALE_FR_UTF8" != "none"; then
306 echo " 1²---++3 1,234 Mi" |
307 LC_ALL
=C
sort --debug -k2g -k1b,1
308 echo " 1²---++3 1,234 Mi" |
309 LC_ALL
=$LOCALE_FR_UTF8 sort --debug -k2g -k1b,1
310 echo "+1234 1234Gi 1,234M" |
311 LC_ALL
=$LOCALE_FR_UTF8 sort --debug -k1,1n
-k1,1g \
312 -k1,1h
-k2,2n
-k2,2g
-k2,2h
-k3,3n
-k3,3g
-k3,3h
314 compare out exp || fail
=1