diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2006-08-16 09:06:39 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2006-08-16 09:06:39 +0000 |
commit | 72f362cf2c8200e57d7759628bb1ffff105dd631 (patch) | |
tree | 7bd47e38cad2d36754cf2ddc4c33d37bc915d4ef /Src/Modules | |
parent | 77321097e70b492090ab0364dadc1329ecc0b0d8 (diff) | |
download | zsh-72f362cf2c8200e57d7759628bb1ffff105dd631.tar.gz zsh-72f362cf2c8200e57d7759628bb1ffff105dd631.tar.xz zsh-72f362cf2c8200e57d7759628bb1ffff105dd631.zip |
22610: allow zstyle -L to have arguments
Diffstat (limited to 'Src/Modules')
-rw-r--r-- | Src/Modules/zutil.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index c2298a782..3ed1f9e16 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -268,9 +268,10 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) zwarnnam(nam, "invalid argument: %s", args[0]); return 1; } - if (oc == 'L') + if (oc == 'L') { list = 2; - else if (oc == 'e') { + args++; + } else if (oc == 'e') { eval = add = 1; args++; } @@ -305,13 +306,44 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) Style s; Stypat p; char **v; + char *context, *stylename; + Patprog contprog; + + switch (arrlen(args)) { + case 2: + context = args[0]; + stylename = args[1]; + break; + + case 1: + context = args[0]; + stylename = NULL; + break; + + case 0: + context = stylename = NULL; + break; + + default: + zwarnnam(nam, "too many arguments"); + return 1; + } + if (context) { + tokenize(context); + contprog = patcompile(context, PAT_STATIC, NULL); + } else + contprog = NULL; for (s = zstyles; s; s = s->next) { if (list == 1) { quotedzputs(s->name, stdout); putchar('\n'); } + if (stylename && strcmp(s->name, stylename) != 0) + continue; for (p = s->pats; p; p = p->next) { + if (contprog && !pattry(contprog, p->pat)) + continue; if (list == 1) printf("%s %s", (p->eval ? "(eval)" : " "), p->pat); else { |