diff options
author | Vlad Glagolev <vaygr@users.noreply.github.com> | 2017-10-08 00:02:29 -0400 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2017-10-08 09:32:29 +0530 |
commit | d835f72c6c285ae79dfad9a663852a8c2c82d030 (patch) | |
tree | 90614fd69dafe27eced2778d786557d2064a77d9 /nnn.c | |
parent | 8959a5b57dd75a0a0402fedd7a3705146631d419 (diff) | |
download | nnn-d835f72c6c285ae79dfad9a663852a8c2c82d030.tar.gz |
Fix segfault when SHLVL env var is not available (#52)
Diffstat (limited to 'nnn.c')
-rw-r--r-- | nnn.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -559,6 +559,7 @@ spawn(char *file, char *arg1, char *arg2, char *dir, uchar flag) { pid_t pid; int status; + char *shlvl; if (flag & F_NORMAL) exitcurses(); @@ -568,10 +569,12 @@ spawn(char *file, char *arg1, char *arg2, char *dir, uchar flag) if (dir != NULL) status = chdir(dir); + shlvl = getenv("SHLVL"); + /* Show a marker (to indicate nnn spawned shell) */ - if (flag & F_MARKER) { + if (flag & F_MARKER && shlvl != NULL) { printf("\n +-++-++-+\n | n n n |\n +-++-++-+\n\n"); - printf("Spawned shell level: %d\n", atoi(getenv("SHLVL")) + 1); + printf("Spawned shell level: %d\n", atoi(shlvl) + 1); } /* Suppress stdout and stderr */ |