From 1ee57e92447781b5ff79aaa7c55f6468fc84a37d Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 18 Jan 2019 22:54:09 +0100 Subject: [PATCH] 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. --- tests/realpath.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/realpath.in b/tests/realpath.in index fba895f15..fc39889fe 100644 --- a/tests/realpath.in +++ b/tests/realpath.in @@ -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