tests/realpath.in: We want to delete $PWD, darnit!

Illumos/OpenIndiana/SunOS/Solaris has an rm/rmdir that tries to
protect the user by not allowing them to delete $PWD.

Normally, this would be a good thing as deleting $PWD is a stupid
thing to do. Except in this case, we absolutely need to do that.

So instead we weasel around it by invoking an sh to cd out of the
directory to then invoke an `rmdir` to delete it. That should throw
off any attempts at protection (we could also have tried $PWD/. or
similar, but that's possibly still protected against).

This is the last failing test on
Illumos/OpenIndiana/SunOS/Solaris/afunnyquip, so:

Fixes #5472.
This commit is contained in:
Fabian Homborg 2019-01-18 22:54:09 +01:00
parent c62d95e428
commit 1ee57e9244

View File

@ -35,7 +35,9 @@ builtin realpath /def///
# Verify `realpath .` when cwd is a deleted directory gives a no such file or dir error.
set -l tmpdir (mktemp -d)
pushd $tmpdir
rmdir $tmpdir
# Solaris rmdir tries to protect against deleting $PWD.
# But that's what we want to test, so we weasel around it.
sh -c "cd ..; rmdir $tmpdir"
builtin realpath .
popd