From d254450d9dcf29ee08df42e2594cb86abc1d54d3 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 5 Dec 2025 01:29:03 -0500 Subject: unalf: Add -n and -s options. --- src/opts.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/opts.c') diff --git a/src/opts.c b/src/opts.c index 977a10d..06ad9dc 100644 --- a/src/opts.c +++ b/src/opts.c @@ -1,6 +1,6 @@ #include "unalf.h" -#define OPTIONS "aefFklLopqtTvVd:x:" +#define OPTIONS "aefFklLon:pqstTvVd:x:" /* uncomment to test exclude/include glob lists */ // #define DEBUG_GLOBS @@ -25,6 +25,10 @@ static void show_globs(void) { } #endif +int parsenum(const char opt, const char *arg) { + return atoi(arg); /* TODO: use strtol(), die on error */ +} + void parse_opts(int argc, char * const *argv) { int opt; char **ig; @@ -41,9 +45,11 @@ void parse_opts(int argc, char * const *argv) { case 'F': opts.force++; break; case 'l': opts.listonly++; opts.testonly = 0; break; case 'L': opts.lowercase++; break; + case 'n': opts.extract_num = parsenum('n', optarg); break; case 'o': opts.overwrite++; break; case 'p': opts.extract_to_stdout++; opts.quiet++; break; case 'q': opts.quiet++; break; + case 's': opts.split++; opts.testonly = 0; opts.listonly = 0; break; case 't': opts.testonly++; opts.listonly = 0; break; case 'T': opts.ignore_datetime = 1; break; case 'v': opts.listonly = 1; opts.testonly = 0; opts.verbose_list++; break; -- cgit v1.2.3