mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-23 16:40:24 +02:00
32136: fix problem with kshglob.
Non-pattern characters that could be followed by "(" to introduce a ksh glob but weren't caused failures.
This commit is contained in:
parent
f06851f50d
commit
db23c63005
4 changed files with 46 additions and 5 deletions
|
@ -1,5 +1,9 @@
|
|||
2013-12-16 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 32136: Src/pattern.c, Src/zsh.h, Test/D02glob.ztst:
|
||||
fix problem with +*, @*, !* when kshglob is set introduced
|
||||
by pattern disable feature.
|
||||
|
||||
* unposted: NEWS: add ZLE_PROMPT_INDENT.
|
||||
|
||||
* Patrick Oscity + pws: 32114: Doc/Zsh/params.yo,
|
||||
|
|
|
@ -1265,12 +1265,18 @@ patcomppiece(int *flagp, int paren)
|
|||
* the character following is an end-of-segment character. Thus
|
||||
* tildes are not special if there is nothing following to
|
||||
* be excluded.
|
||||
*
|
||||
* Don't look for X()-style kshglobs at this point; we've
|
||||
* checked above for the case with parentheses and we don't
|
||||
* want to match without parentheses.
|
||||
*/
|
||||
if (kshchar || (memchr(zpc_special, *patparse, ZPC_COUNT) &&
|
||||
(*patparse != zpc_special[ZPC_TILDE] ||
|
||||
patparse[1] == '/' ||
|
||||
!memchr(zpc_special, patparse[1], ZPC_SEG_COUNT))))
|
||||
if (kshchar ||
|
||||
(memchr(zpc_special, *patparse, ZPC_NO_KSH_GLOB) &&
|
||||
(*patparse != zpc_special[ZPC_TILDE] ||
|
||||
patparse[1] == '/' ||
|
||||
!memchr(zpc_special, patparse[1], ZPC_SEG_COUNT)))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remember the previous character for backtracking */
|
||||
|
|
|
@ -1417,7 +1417,11 @@ enum zpc_chars {
|
|||
ZPC_HAT, /* ^ for exclusion (extended glob) */
|
||||
ZPC_HASH, /* # for repetition (extended glob) */
|
||||
ZPC_BNULLKEEP, /* Special backslashed null not removed */
|
||||
ZPC_KSH_QUEST, /* ? for ?(...) in KSH_GLOB */
|
||||
/*
|
||||
* These characters are only valid before a parenthesis
|
||||
*/
|
||||
ZPC_NO_KSH_GLOB,
|
||||
ZPC_KSH_QUEST = ZPC_NO_KSH_GLOB, /* ? for ?(...) in KSH_GLOB */
|
||||
ZPC_KSH_STAR, /* * for *(...) in KSH_GLOB */
|
||||
ZPC_KSH_PLUS, /* + for +(...) in KSH_GLOB */
|
||||
ZPC_KSH_BANG, /* ! for !(...) in KSH_GLOB */
|
||||
|
|
|
@ -499,3 +499,30 @@
|
|||
)
|
||||
0:No error with empty null glob with (N).
|
||||
>
|
||||
|
||||
(setopt kshglob
|
||||
test_array=(
|
||||
'+fours' '+*'
|
||||
'@titude' '@*'
|
||||
'!bang' '!*'
|
||||
# and check they work in the real kshglob cases too...
|
||||
'+bus+bus' '+(+bus|-car)'
|
||||
'@sinhats' '@(@sinhats|wrensinfens)'
|
||||
'!kerror' '!(!somethingelse)'
|
||||
# and these don't match, to be sure
|
||||
'+more' '+(+less)'
|
||||
'@all@all' '@(@all)'
|
||||
'!goesitall' '!(!goesitall)'
|
||||
)
|
||||
for str pat in $test_array; do
|
||||
eval "[[ $str = $pat ]]" && print "$str matches $pat"
|
||||
done
|
||||
true
|
||||
)
|
||||
0:kshglob option does not break +, @, ! without following open parenthesis
|
||||
>+fours matches +*
|
||||
>@titude matches @*
|
||||
>!bang matches !*
|
||||
>+bus+bus matches +(+bus|-car)
|
||||
>@sinhats matches @(@sinhats|wrensinfens)
|
||||
>!kerror matches !(!somethingelse)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue