Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: zsh-3.1.2-zefram3: ksh globbing syntax
- X-seq: zsh-workers 3764
- From: Peter Stephenson <pws@xxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: zsh-3.1.2-zefram3: ksh globbing syntax
- Date: Fri, 06 Feb 1998 12:28:46 +0100
This patch implements (as far as I know, completely, at least up to
lexical differences) the ksh globbing syntax. This was one of
the major remaining incompatibilities. The option KSH_GLOB has been
created to control this. With this on, parentheses are only
recognised in patterns in the following combinations:
KSH_GLOB Normal zsh equivalent
------- ---------------------
@(...) (...)
*(...) (...)#
+(...) (...)##
?(...) (...|)
!(...) (*~...) or (after fix) (^...)
-(...) pattern(...) (qualifiers)
Introducing a new symbol for qualifiers was basically forced; there is
just too much scope for confusion otherwise. As this is now explicit,
-(...) at the end of a pattern with KSH_GLOB is enough to turn on
globbing. In other words, foobar-(.) will fail unless foobar exists
and is a regular file. I could easily change this. (Of course I
haven't touch the behaviour without KSH_GLOB.)
The lexical difference referred to above is that in ksh, both the `('
and the character before must be unquoted, while in my implementation
only the `(' need be. It just seemed too much of a waste of time
forcing the lexical analyser to tokenise @, ! and - when this aspect
of zsh is any case totally different from ksh. If ksh finds a left
parenthesis without one of the five tokens in front, (it doesn't know
about -(...), of course) it flags an error, so any functional ksh code
will work.
Note that SH_GLOB is respected, i.e. a @(...) or whatever resulting
from a parameter expansion is not treated specially, in agreement with
ksh.
There are a couple of other associated fixes:
1) As hinted at, the EXTENDED_GLOB ^ works properly if at the
start of a set of parentheses, so that (^...) is like (*~(...)),
and is in fact implemented that way. Anywhere else the older,
rather cruder, parsing is used. This comes as a side effect of
implementing !(...), it takes very little extra code. Unfortunately
it is easy to confuse an expression like this with a set of
qualifiers, but there's no way of fixing that, you just have to type
the more confusing but scarcely longer (*~..) (or (*~(...|...)) if
there are |'s in the pattern).
2) A bug fix for the closure code was necessary (this hunk is actually
independent of the rest):
[[ fofoofoo = (fo|foo)# ]]
failed, because the alternation code didn't search for the longest
match.
One question: when patterns are used in condtions and case statements,
the shell adds an extra layer of parentheses around them: `pattern'
becomes `(pattern)' which now has to be `@(pattern)' for KSH_GLOB. I
couldn't see any reason for this grotesquery; everything seems to work
without it. Does anyone know? I've left it in just in case.
[It's nothing to do with the optional parentheses in `case' patterns,
which I've had to handle specially:
case $foo in
(pat1|pat2) action;;
esac
was passing the full (pat1|pat2) through, but the parentheses need to
be stripped for KSH_GLOB.]
begin 644 ksh_glob.dif.gz
M'XL("#CQVC0``VMS:%]G;&]B+F1I9@#</'M?VT:V?[N?8@C=(MG"6'X!IH20
MA#QN26"#L[MW<YNL+(]!C2VYDLPCA7[V>QXS(\F6"6F2V_3RRT.:.>?,S'F?
MF1'5:E4\COR-?R=G&_)R&M:OHOK[Y.QT'`TJ_9D4_^6%PFT)U^VU&[W.EG"W
MM[>^6U]?GT>J/(D#\40.A.@*M]%K-GO-+@-7BS_X+MJ;;:>]U1#4(,0T"(?R
MTCKX5__@Y>.#Q^^>'AX]=,0LD2(:V="?GDGQGS2UWMIK#CW\;J\)+QS2\RH\
M^V=>[/FIC!/AC9-(#&48I5)X8NJET!KNB`AHQ!=!(H&<)2]].4W%*(J!B@C"
M(`V\L2;LB$1*$49#&<N1]208R]";2'%P.?7")(A"V_YN!6=T);P8X5*1QM)+
MY5`D4^D#H?&5&%S1G),S.1[7843XTX?WBR@>BB`1L9R./1\P+H+T#&8Y#I(4
MEBJ2*$8Z(S5F`D2\5$R\U#]37%#KJ0OQ?`1C<U\0GNH.I#Z*9N'0R28@3H-S
MF9#0F.]M`<_K_^_Y3CS"5Z#_T\DS6AW2B*8ID$-.)3)U!*KZ`%DH]4C81<M)
MX^#T%*8S1,(@)CE*`7\*XX=`-P&P:2Q!C@P0A<@W&C''%US=BN;?`W@`"OA8
M`_8!'_!Q';LOSB2R"MMH;2AY0P9G].LLPL5:Z5DT.SUC7A3F,IF!%B'N0"I@
M^UO1O3(?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