nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 940b5eaad116232c20de7405bbb7ba4a2eb8e779
parent fdd946c02cd1c7c5f04914f05540ced73ab5775e
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue,  5 Apr 2022 12:23:32 +0200

files: show a warning when the working directory is gone (when used)

Instead of silently opening an empty buffer when the user tries to
open a file in the current but disappeared directory, give a clear
warning about the absence of this directory.

This improves the fix for https://savannah.gnu.org/bugs/?62244.

Diffstat:
Msrc/files.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -351,6 +351,14 @@ bool has_valid_path(const char *filename) struct stat parentinfo; bool validity = FALSE; + if (strcmp(parentdir, ".") == 0) { + char *currentdir = realpath(".", NULL); + + if (currentdir == NULL) + statusline(ALERT, _("The working directory has disappeared")); + + free(currentdir); + } else if (stat(parentdir, &parentinfo) == -1) { if (errno == ENOENT) /* TRANSLATORS: Keep the next ten messages at most 76 characters. */