2 # make sure --dired option works
4 # Copyright (C) 2001-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
23 # Check with constant positions
24 mkdir dir || framework_failure_
30 //DIRED-OPTIONS// --quoting-style=literal
32 for opt
in '-l' '' '--hyperlink' '-x'; do
33 LC_MESSAGES
=C
ls $opt -R --dired dir
> out || fail
=1
34 compare exp out || fail
=1
38 # Check with varying positions (due to usernames etc.)
39 # Also use multibyte characters to show --dired counts bytes not characters
40 touch dir
/1a dir
/2á || framework_failure_
41 mkdir
-p dir
/3dir || framework_failure_
43 ls -l --dired dir
> out || fail
=1
45 dired_values
=$
(grep "//DIRED//" out| cut
-d' ' -f2-)
46 expected_files
="1a 2á 3dir"
48 dired_count
=$
(printf '%s\n' $dired_values |
wc -l)
49 expected_count
=$
(printf '%s\n' $expected_files |
wc -l)
51 if test "$expected_count" -ne $
(($dired_count / 2)); then
52 echo "Mismatch in number of files!" \
53 "Expected: $expected_count, Found: $(($dired_count / 2))"
57 # Split the values into pairs and extract the filenames
60 while test "$#" -gt 0; do
61 extracted_filename
=$
(head -c "$2" out |
tail -c+"$(($1 + 1))")
62 expected_file
=$
(echo $expected_files | cut
-d' ' -f$index)
63 if test "$extracted_filename" != "$expected_file"; then
64 echo "Mismatch! Expected: $expected_file, Found: $extracted_filename"