]> Sergey Matveev's repositories - nnn.git/commitdiff
account for realpath failure
authorNRK <nrk@disroot.org>
Mon, 20 Jun 2022 15:49:41 +0000 (21:49 +0600)
committerNRK <nrk@disroot.org>
Mon, 20 Jun 2022 15:49:41 +0000 (21:49 +0600)
realpath may fail, in which case fallback to mkpath.

src/nnn.c

index 8b0db0df9582dfa1c559bf9a0965f83da9a70285..0b749d7b9350940d91fba1d594193cd5375afb08 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -6913,13 +6913,11 @@ nochange:
                        }
 
                        pent = &pdents[cur];
-                       if (g_state.selbm) {
-                               S_ISLNK(pent->mode)
-                                       ? (realpath(pent->name, newpath) && xstrsncpy(path, lastdir, PATH_MAX))
-                                       : mkpath(path, pent->name, newpath);
-                               g_state.selbm = 0;
-                       } else
+                       if (!g_state.selbm || !(S_ISLNK(pent->mode) &&
+                                               realpath(pent->name, newpath) &&
+                                               xstrsncpy(path, lastdir, PATH_MAX)))
                                mkpath(path, pent->name, newpath);
+                       g_state.selbm = 0;
                        DPRINTF_S(newpath);
 
                        /* Visit directory */