]> Sergey Matveev's repositories - nnn.git/commitdiff
Ensure script to run is not a directory
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 8 Dec 2018 13:14:28 +0000 (18:44 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 8 Dec 2018 13:14:28 +0000 (18:44 +0530)
src/nnn.c

index 4b51ec7bf80412964c628f519495b7066fa473ec..e5f0d00c57e38c8a6cda337fe709a8a1484b7a61 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3404,12 +3404,17 @@ nochange:
                                                tmp = newpath;
                                        }
 
-                                       /* Check if file exists */
-                                       if (access(tmp, F_OK) == -1) {
+                                       if (lstat(tmp, &sb) == -1) {
                                                printwarn();
                                                goto nochange;
                                        }
 
+                                       /* Check if it's a directory */
+                                       if (S_ISDIR(sb.st_mode)) {
+                                               printmsg("directory");
+                                               goto nochange;
+                                       }
+
                                        dir = NULL; /* dir used as temp var */
                                        if (ndents)
                                                dir = dents[cur].name;