diff options
author | dana <dana@dana.is> | 2019-03-12 19:01:18 -0500 |
---|---|---|
committer | dana <dana@dana.is> | 2019-03-12 19:03:56 -0500 |
commit | 632023acc2feed519659926bf320d303562a5713 (patch) | |
tree | 69d05e6a9c778ed99f11f1a119bb71fc5a306535 /Src/Modules/zutil.c | |
parent | 36290f3e8e8cf3c69856bc9c5c08ddeccd1aebf2 (diff) | |
download | zsh-632023acc2feed519659926bf320d303562a5713.tar.gz zsh-632023acc2feed519659926bf320d303562a5713.tar.xz zsh-632023acc2feed519659926bf320d303562a5713.zip |
44100: zparseopts: Add -F option, completion, tests; improve documentation
* Enable zparseopts to perform basic usage validation (aborting on an unrecognised option-like parameter) * Officially document the resolution of ambiguous option specs
Diffstat (limited to 'Src/Modules/zutil.c')
-rw-r--r-- | Src/Modules/zutil.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index 19a8306b5..c4fe4a15e 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -1644,7 +1644,7 @@ static int bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) { char *o, *p, *n, **pp, **aval, **ap, *assoc = NULL, **cp, **np; - int del = 0, flags = 0, extract = 0, keep = 0; + int del = 0, flags = 0, extract = 0, fail = 0, keep = 0; Zoptdesc sopts[256], d; Zoptarr a, defarr = NULL; Zoptval v; @@ -1681,6 +1681,14 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) } extract = 1; break; + case 'F': + if (o[2]) { + args--; + o = NULL; + break; + } + fail = 1; + break; case 'K': if (o[2]) { args--; @@ -1843,6 +1851,10 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) if (!(d = lookup_opt(o + 1))) { while (*++o) { if (!(d = sopts[STOUC(*o)])) { + if (fail) { + zwarnnam(nam, "bad option: %c", *o); + return 1; + } o = NULL; break; } |