From 7f71df09051cd68bc4355bccaf3e8df1616acf4f Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 5 Sep 2021 02:12:34 +0200 Subject: [PATCH] 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 --- CHANGELOG.rst | 1 + src/builtin_cd.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5c4dcb39f..92487824e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 ------------------------ diff --git a/src/builtin_cd.cpp b/src/builtin_cd.cpp index 9846d8dfd..03cfd9bc0 100644 --- a/src/builtin_cd.cpp +++ b/src/builtin_cd.cpp @@ -117,7 +117,7 @@ maybe_t 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;