From b2d08a2155afe05d2dd6a01b6a2d2c5035d30b45 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 26 Sep 2008 09:11:27 +0000 Subject: 25744: dynamic named directories and further doshfunc() simplification --- Test/D01prompt.ztst | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'Test/D01prompt.ztst') diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst index 361847aa1..84f9c7cbe 100644 --- a/Test/D01prompt.ztst +++ b/Test/D01prompt.ztst @@ -1,5 +1,7 @@ %prep + mkdir prompt.tmp + cd prompt.tmp mydir=$PWD SHLVL=2 setopt extendedglob @@ -104,3 +106,44 @@ print "Years do not agree in $date2, $date3" fi 0:Dates produced by prompt escapes + + mkdir foo + mkdir foo/bar + mkdir foo/bar/rod + (zsh_directory_name() { + emulate -L zsh + setopt extendedglob + local -a match mbegin mend + if [[ $1 = d ]]; then + if [[ $2 = (#b)(*bar)/rod ]]; then + reply=(barmy ${#match[1]}) + else + return 1 + fi + else + if [[ $2 = barmy ]]; then + reply=($mydir/foo/bar) + else + return 1 + fi + fi + } + # success + print ~[barmy]/anything + cd foo/bar/rod + print -P %~ + # failure + setopt nonomatch + print ~[scuzzy]/rubbish + cd ../.. + print -P %~ + # catastrophic failure + unsetopt nonomatch + print ~[scuzzy]/rubbish + ) +1q:Dynamic named directories +>$mydir/foo/bar/anything +>~[barmy]/rod +>~[scuzzy]/rubbish +>~mydir/foo +?(eval):33: no directory expansion: ~[scuzzy] -- cgit 1.4.1