aboutsummaryrefslogtreecommitdiffstats
path: root/noice.c
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2014-10-21 11:29:41 +0100
committersin <sin@2f30.org>2014-10-21 11:29:41 +0100
commit5999cef3967293c53faca42941e6090f4fd99e28 (patch)
tree3eee69dcb5fde2e468f69f99fd6f5db433b9a1ea /noice.c
parent4c330409b0c94b7c9ef8ef987f216c93eeca710f (diff)
downloadnoice-5999cef3967293c53faca42941e6090f4fd99e28.tar.gz
Default to cwd if not argument is provided
Diffstat (limited to 'noice.c')
-rw-r--r--noice.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/noice.c b/noice.c
index d78cf5e..3845980 100644
--- a/noice.c
+++ b/noice.c
@@ -6,6 +6,7 @@
#include <dirent.h>
#include <curses.h>
#include <libgen.h>
+#include <limits.h>
#include <locale.h>
#include <regex.h>
#include <stdlib.h>
@@ -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);
Un proyecto texto-plano.xyz