mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Always use realpath() and properly chdir() so relative changes via 'c' work
This commit is contained in:
parent
56252bdf98
commit
3808dde641
12
noice.c
12
noice.c
|
@ -375,7 +375,7 @@ browse(const char *ipath, const char *ifilter)
|
||||||
struct entry *dents;
|
struct entry *dents;
|
||||||
int i, n, cur;
|
int i, n, cur;
|
||||||
int r, ret;
|
int r, ret;
|
||||||
char *path = strdup(ipath);
|
char *path = realpath(ipath, NULL);
|
||||||
char *filter = strdup(ifilter);
|
char *filter = strdup(ifilter);
|
||||||
regex_t filter_re;
|
regex_t filter_re;
|
||||||
char *cwd;
|
char *cwd;
|
||||||
|
@ -391,6 +391,9 @@ begin:
|
||||||
if (dirp == NULL) {
|
if (dirp == NULL) {
|
||||||
printwarn();
|
printwarn();
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
} else {
|
||||||
|
if (chdir(path) == -1)
|
||||||
|
printwarn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search filter */
|
/* Search filter */
|
||||||
|
@ -607,13 +610,9 @@ nochange:
|
||||||
cur = 0;
|
cur = 0;
|
||||||
goto out;
|
goto out;
|
||||||
case SEL_SH:
|
case SEL_SH:
|
||||||
if (chdir(path) == -1)
|
|
||||||
printwarn();
|
|
||||||
exitcurses();
|
exitcurses();
|
||||||
spawn("/bin/sh", NULL);
|
spawn("/bin/sh", NULL);
|
||||||
initcurses();
|
initcurses();
|
||||||
if (chdir(ipath) == -1)
|
|
||||||
printwarn();
|
|
||||||
break;
|
break;
|
||||||
case SEL_CD:
|
case SEL_CD:
|
||||||
/* Read target dir */
|
/* Read target dir */
|
||||||
|
@ -630,7 +629,8 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
} else {
|
} else {
|
||||||
free(path);
|
free(path);
|
||||||
path = tmp;
|
path = realpath(tmp, NULL);
|
||||||
|
free(tmp);
|
||||||
free(filter);
|
free(filter);
|
||||||
filter = strdup(ifilter); /* Reset filter */
|
filter = strdup(ifilter); /* Reset filter */
|
||||||
DPRINTF_S(path);
|
DPRINTF_S(path);
|
||||||
|
|
Loading…
Reference in a new issue