mirror of
https://github.com/jarun/nnn.git
synced 2024-11-11 03:26:15 +03:00
Default to cwd if not argument is provided
This commit is contained in:
parent
4c330409b0
commit
5999cef396
11
noice.c
11
noice.c
@ -6,6 +6,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -613,9 +614,17 @@ out:
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *ipath = argv[1] != NULL ? argv[1] : "/";
|
char cwd[PATH_MAX], *ipath;
|
||||||
char *ifilter = "^[^.].*"; /* Hide dotfiles */
|
char *ifilter = "^[^.].*"; /* Hide dotfiles */
|
||||||
|
|
||||||
|
if (argv[1] != NULL) {
|
||||||
|
ipath = argv[1];
|
||||||
|
} else {
|
||||||
|
ipath = getcwd(cwd, sizeof(cwd));
|
||||||
|
if (ipath == NULL)
|
||||||
|
ipath = "/";
|
||||||
|
}
|
||||||
|
|
||||||
/* Test initial path */
|
/* Test initial path */
|
||||||
if (!testopendir(ipath))
|
if (!testopendir(ipath))
|
||||||
printerr(1, ipath);
|
printerr(1, ipath);
|
||||||
|
Loading…
Reference in New Issue
Block a user