g Apply the following modifier once to each word.
a (+) Apply the following modifier as many times as possible to a
single word. `a' and `g' can be used together to apply a
modifier globally. With the `s' modifier, only the pat‐
terns contained in the original word are substituted, not
patterns that contain any substitution result.
...yet that wasn't actually true in practice, which resulted in very amusing problems.
I've changed the scalar dolmcnt and dol_flag_a to be array to effectively track the state of those two meta-modifiers per modifier they affect. This is done by counting, but since this was consumed in only one place (setDolp) it's probably fine.
The following are now possible, and, to me, they seem valid cases per the man pages and according to common sense:
tcsh> set x=(aa bb aa bb)
tcsh> echo $x:gas/a/c/:gs/b/d/
cc db cc db
tcsh> foreach i ( "$x:gas/a/c/:q" )
foreach? echo $i
foreach? end
cc bb cc bb
tcsh> set x=(aa bb aa bb)
tcsh> echo $x:gas/a/q/:gs/b/w/:s/b/e/
qq we qq wb
I had to update sh.lex.c because it kinda contradicted sh.dol.c and the man page: it only accepted :gas once, subsequently complaining a is an invalid modifier.
This has irritated me for quite some time.
The man pages state:
...yet that wasn't actually true in practice, which resulted in very amusing problems.
I've changed the scalar
dolmcnt
anddol_flag_a
to be array to effectively track the state of those two meta-modifiers per modifier they affect. This is done by counting, but since this was consumed in only one place (setDolp
) it's probably fine.The following are now possible, and, to me, they seem valid cases per the man pages and according to common sense:
I had to update
sh.lex.c
because it kinda contradictedsh.dol.c
and the man page: it only accepted:gas
once, subsequently complaininga
is an invalid modifier.