tests: tee: avoid false failure due to fifo usage
[coreutils.git] / tests / ls / hyperlink.sh
blob970e062a3329541c3ebe9d34ae42d2a3ac806de0
1 #!/bin/sh
2 # Test --hyperlink processing
4 # Copyright (C) 2017-2023 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_ ls
22 # lookup based on first letter
23 encode() {
24 printf '%s\n' \
25 'sp%20ace' 'ques%3ftion' 'back%5cslash' 'encoded%253Fquestion' 'testdir' \
26 "$1" |
27 sort -k1,1.1 -s | uniq -w1 -d
30 ls_encoded() {
31 ef=$(encode "$1")
32 echo "$ef" | grep 'dir$' >/dev/null && dir=: || dir=''
33 printf '\033]8;;file:///%s\a%s\033]8;;\a%s\n' \
34 "$ef" "$1" "$dir"
37 # These could be encoded, so remove from consideration
38 strip_host_and_path() {
39 sed 's|file://.*/|file:///|'
42 mkdir testdir || framework_failure_
44 cd testdir
45 ls_encoded "testdir" > ../exp.t || framework_failure_
46 for f in 'back\slash' 'encoded%3Fquestion' 'ques?tion' 'sp ace'; do
47 touch "$f" || framework_failure_
48 ls_encoded "$f" >> ../exp.t || framework_failure_
49 done
51 ln -s testdir testdirl || framework_failure_
52 (cat exp.t && printf '\n' && sed 's/[^\/]testdir/&l/' exp.t) > exp \
53 || framework_failure_
54 ls --hyper testdir testdirl >out.t || fail=1
55 strip_host_and_path <out.t >out || framework_failure_
56 compare exp out || fail=1
58 ln -s '/probably_missing' testlink || framework_failure_
59 ls -l --hyper testlink > out.t || fail=1
60 strip_host_and_path <out.t >out || framework_failure_
61 grep 'file:///probably_missing' out || fail=1
63 Exit $fail