diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-02-19 18:24:11 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-02-19 18:24:38 +0100 |
commit | 573edeb13b5b71f90fc1d819af6748cb93d5604e (patch) | |
tree | 3883cc37668f52f979d2d58e3165244ef1ca1259 | |
parent | 6424676d6332cf00e4146d4b45d00cd2eb25d359 (diff) |
libfstree: reject unknown glob options to allow future expansions
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r-- | lib/fstree/fstree_from_file.c | 16 | ||||
-rw-r--r-- | tests/fstree_glob1.txt | 2 | ||||
-rw-r--r-- | tests/fstree_glob2.txt | 2 |
3 files changed, 17 insertions, 3 deletions
diff --git a/lib/fstree/fstree_from_file.c b/lib/fstree/fstree_from_file.c index 3663c1c..d852e0b 100644 --- a/lib/fstree/fstree_from_file.c +++ b/lib/fstree/fstree_from_file.c @@ -297,7 +297,21 @@ static int glob_files(fstree_t *fs, const char *filename, size_t line_num, continue; } - break; + if (extra[0] == '-') { + if (extra[1] == '-' && isspace(extra[2])) { + extra += 2; + while (isspace(*extra)) + ++extra; + break; + } + + fprintf(stderr, "%s: " PRI_SZ ": unknown option.\n", + filename, line_num); + free(ctx.name_pattern); + return -1; + } else { + break; + } } if (*extra == '\0') { diff --git a/tests/fstree_glob1.txt b/tests/fstree_glob1.txt index 28dbecb..0d96391 100644 --- a/tests/fstree_glob1.txt +++ b/tests/fstree_glob1.txt @@ -1,2 +1,2 @@ dir /tarcorpus 0755 0 0 -glob /tarcorpus 0755 0 0 -type d tar +glob /tarcorpus 0755 0 0 -type d -- tar diff --git a/tests/fstree_glob2.txt b/tests/fstree_glob2.txt index be30fcc..f423b4a 100644 --- a/tests/fstree_glob2.txt +++ b/tests/fstree_glob2.txt @@ -1,3 +1,3 @@ dir /tarcorpus 0755 0 0 glob /tarcorpus 0755 0 0 -type d tar -glob /tarcorpus 0644 0 0 -type f -name "*gnu*.tar" tar +glob /tarcorpus 0644 0 0 -type f -name "*gnu*.tar" -- tar |