about summary refs log tree commit diff
path: root/Test/D01prompt.ztst
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-10-24 16:00:48 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-10-24 16:00:48 +0000
commit2f50e20d84e676720674f8a35e1f8df205a42fc3 (patch)
tree02141446bf67f51ca57fa04425de6a7bd32bd15e /Test/D01prompt.ztst
parent337530b4d6ef96bcd0fb50438256e288cf9b729c (diff)
downloadzsh-2f50e20d84e676720674f8a35e1f8df205a42fc3.tar.gz
zsh-2f50e20d84e676720674f8a35e1f8df205a42fc3.tar.xz
zsh-2f50e20d84e676720674f8a35e1f8df205a42fc3.zip
25931: Test for prompt code reentrancy
users/13400: clarify some ksh-like editing issues
Diffstat (limited to 'Test/D01prompt.ztst')
-rw-r--r--Test/D01prompt.ztst54
1 files changed, 54 insertions, 0 deletions
diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
index 84f9c7cbe..3074efe60 100644
--- a/Test/D01prompt.ztst
+++ b/Test/D01prompt.ztst
@@ -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]'