]> git.ipfire.org Git - thirdparty/coreutils.git/commit
ls: issue error message on removed directory
authorColin Watson <cjwatson@debian.org>
Tue, 11 Feb 2020 10:45:46 +0000 (10:45 +0000)
committerPádraig Brady <P@draigBrady.com>
Thu, 27 Feb 2020 14:11:37 +0000 (14:11 +0000)
commit05a99f7d7f8e0999994b760bb6337ca10ea0a14b
tree792a87deec52eeffff8e72ab1dfba9e966a594bb
parent93db70867d2fe8c451a4624a071fed5c4d1f6a7d
ls: issue error message on removed directory

If the current directory has been removed, then "ls" confusingly
produced no output and no error message, indistinguishable from
running on an empty directory.

* src/ls.c (print_dir): Report ENOENT on GNU/Linux if readdir
finds no directory entries at all, not even "." or "..",
and a recheck with the getdents syscall returns ENOENT.
We recheck with getdents() as POSIX states that
"The directory entries for dot and dot-dot are optional".
* tests/ls/removed-directory.sh: New file.
* tests/local.mk (all_tests): Add new test.
* NEWS: Mention the change in behavior.
Reported by Owen Thomas.
NEWS
src/ls.c
tests/local.mk
tests/ls/removed-directory.sh [new file with mode: 0755]