From: sin Date: Tue, 21 Oct 2014 10:29:41 +0000 (+0100) Subject: Default to cwd if not argument is provided X-Git-Tag: v1.0~92^2~214 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=5999cef3967293c53faca42941e6090f4fd99e28;p=nnn.git Default to cwd if not argument is provided --- diff --git a/noice.c b/noice.c index d78cf5e9..38459809 100644 --- a/noice.c +++ b/noice.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -613,9 +614,17 @@ out: int main(int argc, char *argv[]) { - char *ipath = argv[1] != NULL ? argv[1] : "/"; + char cwd[PATH_MAX], *ipath; char *ifilter = "^[^.].*"; /* Hide dotfiles */ + if (argv[1] != NULL) { + ipath = argv[1]; + } else { + ipath = getcwd(cwd, sizeof(cwd)); + if (ipath == NULL) + ipath = "/"; + } + /* Test initial path */ if (!testopendir(ipath)) printerr(1, ipath);