|
@@ -349,6 +349,7 @@ static char *prefixpath; |
|
|
static char *plugindir; |
|
|
static char *plugindir; |
|
|
static char *sessiondir; |
|
|
static char *sessiondir; |
|
|
static char *pnamebuf, *pselbuf; |
|
|
static char *pnamebuf, *pselbuf; |
|
|
|
|
|
static char *mark; |
|
|
#ifndef NOFIFO |
|
|
#ifndef NOFIFO |
|
|
static char *fifopath; |
|
|
static char *fifopath; |
|
|
#endif |
|
|
#endif |
|
@@ -4430,6 +4431,7 @@ static void dentfree(void) |
|
|
{ |
|
|
{ |
|
|
free(pnamebuf); |
|
|
free(pnamebuf); |
|
|
free(dents); |
|
|
free(dents); |
|
|
|
|
|
free(mark); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static blkcnt_t dirwalk(char *path, struct stat *psb) |
|
|
static blkcnt_t dirwalk(char *path, struct stat *psb) |
|
@@ -5228,7 +5230,7 @@ static bool browse(char *ipath, const char *session, int pkey) |
|
|
char newpath[PATH_MAX] __attribute__ ((aligned)); |
|
|
char newpath[PATH_MAX] __attribute__ ((aligned)); |
|
|
char rundir[PATH_MAX] __attribute__ ((aligned)); |
|
|
char rundir[PATH_MAX] __attribute__ ((aligned)); |
|
|
char runfile[NAME_MAX + 1] __attribute__ ((aligned)); |
|
|
char runfile[NAME_MAX + 1] __attribute__ ((aligned)); |
|
|
char *path, *lastdir, *lastname, *dir, *tmp, *mark = NULL; |
|
|
char *path, *lastdir, *lastname, *dir, *tmp; |
|
|
enum action sel; |
|
|
enum action sel; |
|
|
struct stat sb; |
|
|
struct stat sb; |
|
|
int r = -1, presel, selstartid = 0, selendid = 0; |
|
|
int r = -1, presel, selstartid = 0, selendid = 0; |
|
@@ -5352,20 +5354,16 @@ begin: |
|
|
|
|
|
|
|
|
nochange: |
|
|
nochange: |
|
|
/* Exit if parent has exited */ |
|
|
/* Exit if parent has exited */ |
|
|
if (getppid() == 1) { |
|
|
if (getppid() == 1) |
|
|
free(mark); |
|
|
|
|
|
_exit(EXIT_FAILURE); |
|
|
_exit(EXIT_FAILURE); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* If CWD is deleted or moved or perms changed, find an accessible parent */ |
|
|
/* If CWD is deleted or moved or perms changed, find an accessible parent */ |
|
|
if (chdir(path) == -1) |
|
|
if (chdir(path) == -1) |
|
|
goto begin; |
|
|
goto begin; |
|
|
|
|
|
|
|
|
/* If STDIN is no longer a tty (closed) we should exit */ |
|
|
/* If STDIN is no longer a tty (closed) we should exit */ |
|
|
if (!isatty(STDIN_FILENO) && !cfg.picker) { |
|
|
if (!isatty(STDIN_FILENO) && !cfg.picker) |
|
|
free(mark); |
|
|
|
|
|
return EXIT_FAILURE; |
|
|
return EXIT_FAILURE; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sel = nextsel(presel); |
|
|
sel = nextsel(presel); |
|
|
if (presel) |
|
|
if (presel) |
|
@@ -5533,7 +5531,6 @@ nochange: |
|
|
if (cfg.picker && sel == SEL_GOIN) { |
|
|
if (cfg.picker && sel == SEL_GOIN) { |
|
|
appendfpath(newpath, mkpath(path, dents[cur].name, newpath)); |
|
|
appendfpath(newpath, mkpath(path, dents[cur].name, newpath)); |
|
|
writesel(pselbuf, selbufpos - 1); |
|
|
writesel(pselbuf, selbufpos - 1); |
|
|
free(mark); |
|
|
|
|
|
return EXIT_SUCCESS; |
|
|
return EXIT_SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -6473,7 +6470,6 @@ nochange: |
|
|
/* Picker mode: reset buffer or clear file */ |
|
|
/* Picker mode: reset buffer or clear file */ |
|
|
if (sel == SEL_QUITCD || getenv("NNN_TMPFILE")) |
|
|
if (sel == SEL_QUITCD || getenv("NNN_TMPFILE")) |
|
|
cfg.picker ? selbufpos = 0 : write_lastdir(path); |
|
|
cfg.picker ? selbufpos = 0 : write_lastdir(path); |
|
|
free(mark); |
|
|
|
|
|
return sel == SEL_QUITFAIL ? EXIT_FAILURE : EXIT_SUCCESS; |
|
|
return sel == SEL_QUITFAIL ? EXIT_FAILURE : EXIT_SUCCESS; |
|
|
default: |
|
|
default: |
|
|
r = FALSE; |
|
|
r = FALSE; |
|
|