diff options
-rw-r--r-- | rf.1 | 5 | ||||
-rw-r--r-- | rf.c | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/rf.1 b/rf.1 index b4eab3c..9f58417 100644 --- a/rf.1 +++ b/rf.1 @@ -5,6 +5,7 @@ rf \- a tiny and simple file finder .SH SYNOPSIS .SY rf +.OP \-d directory .OP \-lsvw .OP pattern ... @@ -14,6 +15,10 @@ substring) patterns, while respecting any ignore rules in \fBrfignore\fR files. .SH OPTIONS .TP +.BI \-d directory +Search from specified directory, otherwise defaults to current working directory. +. +.TP .BI \-l count Limit to specified matches count. . diff --git a/rf.c b/rf.c index bee1ea9..14acc9d 100644 --- a/rf.c +++ b/rf.c @@ -38,7 +38,8 @@ static void usage(char *error) { fprintf(stderr, "Error: %s\n\n", error); } - fprintf(stderr, "usage: %s [-lsvw] pattern ...\n", __progname); + fprintf( + stderr, "usage: %s [-d directory] [-lsvw] pattern ...\n", __progname); } static int is_child(char *dirname) { @@ -179,6 +180,10 @@ int main(int argc, char **argv) { while ((ch = getopt(argc, argv, "l:svw")) > -1) { switch (ch) { + case 'd': + root = optarg; + break; + case 'h': usage(NULL); exit(EXIT_SUCCESS); @@ -249,7 +254,7 @@ int main(int argc, char **argv) { patterns[i++] = argv[optind++]; } - if (recurse_find(patterns, &pattern_count, ".", &switches)) { + if (recurse_find(patterns, &pattern_count, root, &switches)) { /* finished early because we reached the limit */ }; |