1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

25931: Test for prompt code reentrancy

users/13400: clarify some ksh-like editing issues
This commit is contained in:
Peter Stephenson 2008-10-24 16:00:48 +00:00
parent 337530b4d6
commit 2f50e20d84
4 changed files with 73 additions and 2 deletions

View file

@ -1,5 +1,10 @@
2008-10-24 Peter Stephenson <pws@csr.com>
* users/13400: Doc/Zsh/options.yo, Etc/FAQ.yo: clarify some
aspects of ksh-like editing.
* 25931: Test/D01prompt.zsh: test fix in 25930.
* 25930: Src/prompt.c, Src/utils.c: dynamic directory names
may need recursive prompt expansion; memory leak with reverse
expansion of dynamic directory names.

View file

@ -1515,6 +1515,12 @@ pindex(SINGLE_LINE_ZLE)
cindex(editor, single line mode)
item(tt(SINGLE_LINE_ZLE) (tt(-M)) <K>)(
Use single-line command line editing instead of multi-line.
Note that although this is on by default in ksh emulation it only
provides superficial compatibility with the ksh line editor and
reduces the effectiveness of the zsh line editor. As it has no
effect on shell syntax, many users may wish to disable this option
when using ksh emulation interactively.
)
pindex(VI)
item(tt(VI))(

View file

@ -298,7 +298,7 @@ sect(On what machines will it run?)
sect(What's the latest version?)
Zsh 4.2.7 is the latest production version. The latest development
version is 4.3.6; this contains support for multibyte character strings
version is 4.3.7; this contains support for multibyte character strings
(such as UTF-8 locales). All the main features for multibyte
support are now in place, although there is some debugging work
still to be done.
@ -642,7 +642,13 @@ link(2.3)(23).
it() mytt(\) does not escape editing chars (use mytt(^V)).
it() Not all ksh bindings are set (e.g. mytt(<ESC>#); try mytt(<ESC>q)).
it()* mytt(#) in an interactive shell is not treated as a comment by
default.
default.
it() In vi command mode the keys "k" and "j" move the cursor to the
end of the line. To move the cursor to the start instead, use
verb(
bindkey -M vicmd 'k' vi-up-line-or-history
bindkey -M vicmd 'j' vi-down-line-or-history
)
)
it() Built-in commands:
itemize(

View file

@ -147,3 +147,57 @@
>~[scuzzy]/rubbish
>~mydir/foo
?(eval):33: no directory expansion: ~[scuzzy]
(
zsh_directory_name() {
emulate -L zsh
setopt extendedglob
local -a match mbegin mend
if [[ $1 = n ]]; then
if [[ $2 = *:l ]]; then
reply=(${2%%:l}/very_long_directory_name)
return 0
else
return 1
fi
else
if [[ $2 = (#b)(*)/very_long_directory_name ]]; then
reply=(${match[1]}:l ${#2})
return 0
else
return 1
fi
fi
}
parent=$PWD
dir=$parent/very_long_directory_name
mkdir $dir
cd $dir
fn() {
PS4='+%N:%i> '
setopt localoptions xtrace
# The following is the key to the test.
# It invokes zsh_directory_name which does PS4 output stuff
# while we're doing prompt handling for the parameter
# substitution. This checks recursion works OK.
local d=${(%):-%~}
print ${d//$parent/\<parent\>}
}
fn 2>stderr
# post process error to remove variable contents
while read line; do
# tricky: reply is set to include directory length which is variable
[[ $line = *reply* ]] && continue
print ${line//$parent/\<parent\>}
done <stderr >&2
)
0:Recursive use of prompts
>~[<parent>:l]
?+zsh_directory_name:1> emulate -L zsh
?+zsh_directory_name:2> setopt extendedglob
?+zsh_directory_name:3> local -a match mbegin mend
?+zsh_directory_name:4> [[ d == n ]]
?+zsh_directory_name:12> [[ <parent>/very_long_directory_name == (#b)(*)/very_long_directory_name ]]
?+zsh_directory_name:14> return 0
?+fn:7> local 'd=~[<parent>:l]'
?+fn:8> print '~[<parent>:l]'