aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar sin <sin@2f30.org>2014-10-21 15:52:59 +0100
committerGravatar sin <sin@2f30.org>2014-10-21 15:53:12 +0100
commit3808dde64162455d349ca1075ccbbeb1184a078f (patch)
tree7765d527e3c4e36d7094f318e04d306cfcab852d
parent56252bdf9862806bcfdf2b7521c37489e33e1bad (diff)
downloadnnn-3808dde64162455d349ca1075ccbbeb1184a078f.tar.gz
Always use realpath() and properly chdir() so relative changes via 'c' work
-rw-r--r--noice.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/noice.c b/noice.c
index 9088c83..e288f92 100644
--- a/noice.c
+++ b/noice.c
@@ -375,7 +375,7 @@ browse(const char *ipath, const char *ifilter)
struct entry *dents;
int i, n, cur;
int r, ret;
- char *path = strdup(ipath);
+ char *path = realpath(ipath, NULL);
char *filter = strdup(ifilter);
regex_t filter_re;
char *cwd;
@@ -391,6 +391,9 @@ begin:
if (dirp == NULL) {
printwarn();
goto nochange;
+ } else {
+ if (chdir(path) == -1)
+ printwarn();
}
/* Search filter */
@@ -607,13 +610,9 @@ nochange:
cur = 0;
goto out;
case SEL_SH:
- if (chdir(path) == -1)
- printwarn();
exitcurses();
spawn("/bin/sh", NULL);
initcurses();
- if (chdir(ipath) == -1)
- printwarn();
break;
case SEL_CD:
/* Read target dir */
@@ -630,7 +629,8 @@ nochange:
goto nochange;
} else {
free(path);
- path = tmp;
+ path = realpath(tmp, NULL);
+ free(tmp);
free(filter);
filter = strdup(ifilter); /* Reset filter */
DPRINTF_S(path);