diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2018-12-01 08:06:34 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2018-12-01 08:06:34 +0530 |
commit | 4b9796eae04c9a25e27c8f4328075019ce446c4a (patch) | |
tree | b1b16950138fb09fa2fd28a657a7d2b23c06b3b8 /src/nnn.c | |
parent | d7da4acde04e8c340ddf4ba95c73c6c90f3ad78d (diff) | |
download | nnn-4b9796eae04c9a25e27c8f4328075019ce446c4a.tar.gz |
Fix #157: support one combined arg for EDITOR, PAGER and SHELL
Diffstat (limited to 'src/nnn.c')
-rw-r--r-- | src/nnn.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -293,6 +293,7 @@ static uint idletimeout, copybufpos, copybuflen; static char *copier; static char *editor, *editor_arg; static char *pager, *pager_arg; +static char *shell, *shell_arg; static blkcnt_t ent_blocks; static blkcnt_t dir_blocks; static ulong num_files; @@ -872,7 +873,7 @@ static void getprogarg(char *prog, char **arg) { char *argptr; - while (*prog && *prog != ' ') + while (*prog && !isblank(*prog)) ++prog; if (*prog) { @@ -882,7 +883,7 @@ static void getprogarg(char *prog, char **arg) /* Make sure there are no more args */ while (*argptr) { - if (*argptr == ' ') { + if (isblank(*argptr)) { fprintf(stderr, "Too many args [%s]\n", prog); exit(1); } @@ -2115,15 +2116,15 @@ static int show_help(char *path) if (getenv("PWD")) dprintf(fd, "PWD: %s\n", getenv("PWD")); if (getenv("SHELL")) - dprintf(fd, "SHELL: %s\n", getenv("SHELL")); + dprintf(fd, "SHELL: %s\n", shell); if (getenv("SHLVL")) dprintf(fd, "SHLVL: %s\n", getenv("SHLVL")); if (getenv("VISUAL")) - dprintf(fd, "VISUAL: %s\n", getenv("VISUAL")); + dprintf(fd, "VISUAL: %s\n", editor); else if (getenv("EDITOR")) - dprintf(fd, "EDITOR: %s\n", getenv("EDITOR")); + dprintf(fd, "EDITOR: %s\n", editor); if (getenv("PAGER")) - dprintf(fd, "PAGER: %s\n", getenv("PAGER")); + dprintf(fd, "PAGER: %s\n", pager); dprintf(fd, "\nVersion: %s\n%s\n", VERSION, GENERAL_INFO); close(fd); @@ -3351,8 +3352,6 @@ nochange: break; case SEL_RUN: // fallthrough case SEL_RUNSCRIPT: - run = xgetenv(env, run); - if (sel == SEL_RUNSCRIPT) { tmp = getenv("NNN_SCRIPT"); if (tmp) { @@ -3371,11 +3370,11 @@ nochange: if (ndents) curfile = dents[cur].name; - spawn(run, tmp, curfile, path, F_NORMAL | F_SIGINT); + spawn(shell, tmp, curfile, path, F_NORMAL | F_SIGINT); } else printmsg("set NNN_SCRIPT"); } else { - spawn(run, NULL, NULL, path, F_NORMAL | F_MARKER); + spawn(shell, shell_arg, NULL, path, F_NORMAL | F_MARKER); /* Continue in navigate-as-you-type mode, if enabled */ if (cfg.filtermode) @@ -3600,6 +3599,10 @@ int main(int argc, char *argv[]) pager = xgetenv("PAGER", "less"); getprogarg(pager, &pager_arg); + /* Get SHELL */ + shell = xgetenv("SHELL", "sh"); + getprogarg(shell, &shell_arg); + #ifdef LINUX_INOTIFY /* Initialize inotify */ inotify_fd = inotify_init1(IN_NONBLOCK); |