builtin cd: recognize EPERM, as it's returned by MacOS

Now that we removed EROTTEN which had the same error code as EPERM,
we can give a less confusing error in case a user has not allowed
their terminal access to a directory.

See #8264
This commit is contained in:
Johannes Altmanninger 2021-09-05 02:12:34 +02:00
parent eae9ee7f35
commit 7f71df0905
2 changed files with 2 additions and 1 deletions

View File

@ -67,6 +67,7 @@ Scripting improvements
- Some error messages occuring after fork, like "text file busy" have been replaced by bespoke error messages for fish. This also restores error messages with current glibc versions that removed sys_errlist (:issue:`8234`, :issue:`4183`).
- The ``realpath`` builtin now also squashes leading slashes with the ``--no-symlinks`` option (:issue:`8281`).
- When trying to ``cd`` to a dangling (broken) symbolic link, fish will print an error noting that the target is a broken link (:issue:`8264`).
- On MacOS terminals that are not granted permissions to access a folder, ``cd`` would print a spurious "rotten symlink" error, which has been corrected to "permission denied" (:issue:`8264`).
Interactive improvements
------------------------

View File

@ -117,7 +117,7 @@ maybe_t<int> builtin_cd(parser_t &parser, io_streams_t &streams, const wchar_t *
} else if (best_errno == ENOENT) {
streams.err.append_format(_(L"%ls: The directory '%ls' does not exist\n"), cmd,
dir_in.c_str());
} else if (best_errno == EACCES) {
} else if (best_errno == EACCES || best_errno == EPERM) {
streams.err.append_format(_(L"%ls: Permission denied: '%ls'\n"), cmd, dir_in.c_str());
} else {
errno = best_errno;