Revert "wrealpath: Fail for file/something"

Apparently macOS realpath is broken.

This reverts commit ca1c499069.
This commit is contained in:
Fabian Homborg 2018-11-18 22:54:34 +01:00
parent 3d557518d5
commit 7367e545f2
3 changed files with 3 additions and 7 deletions

View File

@ -414,9 +414,9 @@ maybe_t<wcstring> wrealpath(const wcstring &pathname) {
// If there is no "/", this is a file in $PWD, so give the realpath to that.
narrow_res = realpath(".", tmpbuf);
} else {
// Be sure to include the last "/" to have the penultimate component considered a directory.
// Otherwise "file/something" succeeds.
narrow_res = realpath(narrow_path.substr(0, pathsep_idx + 1).c_str(), tmpbuf);
errno = 0;
// Only call realpath() on the portion up to the last component.
narrow_res = realpath(narrow_path.substr(0, pathsep_idx).c_str(), tmpbuf);
}
if (!narrow_res) return none();

View File

@ -1,3 +1,2 @@
builtin realpath: /this/better/be/an/invalid/path: No such file or directory
builtin realpath: .: No such file or directory
builtin realpath: realpath.out/..: Not a directory

View File

@ -80,7 +80,4 @@ else
echo "unexpected pwd-resolved-to-itself failure: $real_path != $PWD" >&2
end
# Confirm that the penultimate component still needs to be a directory:
builtin realpath realpath.out/..
exit 0