diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-02-16 18:07:21 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-02-16 18:07:21 +0000 |
commit | 755880b19f365c3f98eac5c7de1d8b25f773ace3 (patch) | |
tree | 28f1615267a197c780c3a48921f879c3b2b5529d /sys/src/cmd/rc/code.c | |
parent | c5c79d61e67f2c74a8d57eb1aeea87a23eeadd87 (diff) |
rc: fix globbing with lists (thanks qwx)
Pattern matching with lists no longer works:
; ls /tmp/*.c
/tmp/npage.c
/tmp/pagedebug.c
/tmp/pageold.c
/tmp/scheduler.c
/tmp/writeimagetest.c
; ls /tmp/^(*.c)
ls: /tmp/*.c: '/tmp/*.c' directory entry not found
; 9fs dump
; bind /n/dump/2021/1002/amd64/bin/rc /bin/rc
; rc
; ls /tmp/^(*.c)
/tmp/npage.c
/tmp/pagedebug.c
/tmp/pageold.c
/tmp/scheduler.c
/tmp/writeimagetest.c
the fix:
we have to propagate the glob attribute thru lists
as well. before it was only handled for single words
and propagated thru concatenations...
the Xglob instruction now works on list, and we
propagate the glob attribute thru PAREN and WORDS
and ARGLIST nodes.
also, avoid using negative numbers for the Tree.glob
field as char might be unsigned on some targets.
Diffstat (limited to 'sys/src/cmd/rc/code.c')
-rw-r--r-- | sys/src/cmd/rc/code.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/src/cmd/rc/code.c b/sys/src/cmd/rc/code.c index 958907c57..3b940ccd3 100644 --- a/sys/src/cmd/rc/code.c +++ b/sys/src/cmd/rc/code.c @@ -58,8 +58,8 @@ compile(tree *t) * called on a tree where we expect eigther * a pattern or a string instead of a glob to * remove the GLOB chars from the strings - * or set glob to -1 for pattern so not Xglob - * is inserted when compiling the tree. + * or set glob to 2 for pattern so Xglob + * is not inserted when compiling the tree. */ void noglobs(tree *t, int pattern) @@ -69,13 +69,13 @@ Again: return; if(t->type==WORD && t->glob){ if(pattern) - t->glob=-1; + t->glob=2; else{ deglob(t->str); t->glob=0; } } - if(t->type==WORDS || t->type=='^'){ + if(t->type==PAREN || t->type==WORDS || t->type=='^'){ t->glob=0; noglobs(c1, pattern); t = c0; @@ -425,7 +425,7 @@ outcode(tree *t, int eflag) emitf(Xpipewait); break; } - if(t->glob > 0) + if(t->glob==1) emitf(Xglob); if(t->type!=NOT && t->type!=';') lex->iflast = t->type==IF; |