From ba7c84fe3b20bad017c026e57caa68fae395286a Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 15 May 2022 11:58:40 -0700 Subject: [PATCH] Add an error message when cd fails with ELOOP This error is emitted if you try to `cd` into a symlink loop or very long chain. --- src/builtins/cd.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/builtins/cd.cpp b/src/builtins/cd.cpp index 9e7847d02..82e0f9cdb 100644 --- a/src/builtins/cd.cpp +++ b/src/builtins/cd.cpp @@ -110,6 +110,9 @@ maybe_t builtin_cd(parser_t &parser, io_streams_t &streams, const wchar_t * } else if (!broken_symlink.empty()) { streams.err.append_format(_(L"%ls: '%ls' is a broken symbolic link to '%ls'\n"), cmd, broken_symlink.c_str(), broken_symlink_target.c_str()); + } else if (best_errno == ELOOP) { + streams.err.append_format(_(L"%ls: Too many levels of symbolic links: '%ls'\n"), cmd, + dir_in.c_str()); } else if (best_errno == ENOENT) { streams.err.append_format(_(L"%ls: The directory '%ls' does not exist\n"), cmd, dir_in.c_str());