1#!/bin/sh
2# If ls is asked to list a removed directory (e.g., the parent process's
3# current working directory has been removed by another process), it
4# should not emit an error message merely because the directory is removed.
5
6# Copyright (C) 2020-2023 Free Software Foundation, Inc.
7
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17
18# You should have received a copy of the GNU General Public License
19# along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
21. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
22print_ver_ ls
23
24cwd=$(pwd)
25mkdir d || framework_failure_
26cd d || framework_failure_
27rmdir ../d || skip_ "can't remove working directory on this platform"
28
29# On NFS, 'ls' would run into the error "Stale file handle".
30test -d . || skip_ "can't examine removed working directory on this platform"
31
32ls >"$cwd"/out 2>"$cwd"/err || fail=1
33cd "$cwd" || framework_failure_
34
35compare /dev/null out || fail=1
36compare /dev/null err || fail=1
37
38Exit $fail
39