projects
/
nnn.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8959a5b
)
Fix segfault when SHLVL env var is not available (#52)
author
Vlad Glagolev <vaygr@users.noreply.github.com>
Sun, 8 Oct 2017 04:02:29 +0000 (
00:02
-0400)
committer
Arun Prakash Jana <engineerarun@gmail.com>
Sun, 8 Oct 2017 04:02:29 +0000 (09:32 +0530)
nnn.c
patch
|
blob
|
history
diff --git
a/nnn.c
b/nnn.c
index 450474dff2715f9c09b6f9b3e26766d47ff83734..28335898c81c27680249e7e0e4deb6c78661fc6c 100644
(file)
--- a/
nnn.c
+++ b/
nnn.c
@@
-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 */