aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-12-08 18:44:28 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-12-08 18:44:28 +0530
commit70d1b0d4d8e685331f3f7bd3b92b826fd10ca0c8 (patch)
tree2a9d4063e421ce27c7980676fc3a0f5034bffe08 /src
parent08cfcfea59a8ee0759d3644b06eca597d95d9277 (diff)
downloadnnn-70d1b0d4d8e685331f3f7bd3b92b826fd10ca0c8.tar.gz
Ensure script to run is not a directory
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 4b51ec7..e5f0d00 100644
--- 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;