aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-12-08 17:22:52 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-12-08 17:38:17 +0530
commit7119310a6a0cac82ae792f1a330015eeaf05dbe4 (patch)
treec0eabe8e4a6ca86c9aae9653441611088b16a3a2 /src
parent5d1ca249f90c21e3c379337dd8c6473d56fc1905 (diff)
downloadnnn-7119310a6a0cac82ae792f1a330015eeaf05dbe4.tar.gz
Ensure NNN_SCRIPT(suffix) exists
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c10
-rw-r--r--src/nnn.h4
2 files changed, 10 insertions, 4 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 79dfc63..b88ca38 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3372,8 +3372,8 @@ nochange:
xstrlcpy(lastname, tmp, NAME_MAX + 1);
goto begin;
case SEL_SHELL: // fallthrough
- case SEL_RUNSCRIPT:
- if (sel == SEL_RUNSCRIPT) {
+ case SEL_SCRIPT:
+ if (sel == SEL_SCRIPT) {
tmp = getenv("NNN_SCRIPT");
if (tmp) {
if (getenv("NNN_MULTISCRIPT")) {
@@ -3385,6 +3385,12 @@ nochange:
tmp = newpath;
}
+ /* Check if file exists */
+ if (access(tmp, F_OK) == -1) {
+ printwarn();
+ goto nochange;
+ }
+
dir = NULL; /* dir used as temp var */
if (ndents)
dir = dents[cur].name;
diff --git a/src/nnn.h b/src/nnn.h
index 710bc97..088f5a6 100644
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -81,7 +81,7 @@ enum action {
SEL_RENAMEALL,
SEL_HELP,
SEL_SHELL,
- SEL_RUNSCRIPT,
+ SEL_SCRIPT,
SEL_RUNEDIT,
SEL_RUNPAGE,
SEL_LOCK,
@@ -213,7 +213,7 @@ static struct key bindings[] = {
{ '!', SEL_SHELL },
{ CONTROL(']'), SEL_SHELL },
/* Run a custom script */
- { 'R', SEL_RUNSCRIPT },
+ { 'R', SEL_SCRIPT },
/* Run command with argument */
{ 'e', SEL_RUNEDIT },
{ 'p', SEL_RUNPAGE },