From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26302 invoked from network); 6 Feb 1998 11:38:07 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 6 Feb 1998 11:38:07 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id GAA23454; Fri, 6 Feb 1998 06:26:57 -0500 (EST) Resent-Date: Fri, 6 Feb 1998 06:26:57 -0500 (EST) Message-Id: <199802061128.MAA09157@hydra.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: PATCH: zsh-3.1.2-zefram3: ksh globbing syntax Date: Fri, 06 Feb 1998 12:28:46 +0100 From: Peter Stephenson Resent-Message-ID: <"wOLT-.0.Mk5.1Elsq"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3764 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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@#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#&BB`1L9R./1\P+H+T#&8Y#I(4 MEBJ2*$8Z(S5F`D2\5$R\U#]37%#KJ0OQ?`1C`A:,B'V_+A^'WA%H\&TO/!*A+/)0,:X.-32 M()43B[3TW(NM2]NV@#DO,O#TC*5+NI=;B&#P`AEN`F+71.P*B0E#3`8D(@9" M23%,G6RKTVPYG593V]:?MYZ\WK^%:?K^+$Z`1#"9R&$`%@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