mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Fix segfault when SHLVL env var is not available (#52)
This commit is contained in:
parent
8959a5b57d
commit
d835f72c6c
7
nnn.c
7
nnn.c
|
@ -559,6 +559,7 @@ spawn(char *file, char *arg1, char *arg2, char *dir, uchar flag)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
|
char *shlvl;
|
||||||
|
|
||||||
if (flag & F_NORMAL)
|
if (flag & F_NORMAL)
|
||||||
exitcurses();
|
exitcurses();
|
||||||
|
@ -568,10 +569,12 @@ spawn(char *file, char *arg1, char *arg2, char *dir, uchar flag)
|
||||||
if (dir != NULL)
|
if (dir != NULL)
|
||||||
status = chdir(dir);
|
status = chdir(dir);
|
||||||
|
|
||||||
|
shlvl = getenv("SHLVL");
|
||||||
|
|
||||||
/* Show a marker (to indicate nnn spawned shell) */
|
/* 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("\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 */
|
/* Suppress stdout and stderr */
|
||||||
|
|
Loading…
Reference in a new issue