about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2007-10-14 16:34:15 +0000
committerBart Schaefer <barts@users.sourceforge.net>2007-10-14 16:34:15 +0000
commit9b33f07e10ae7d8e7974a1f9bd095273a1eb3996 (patch)
treee99057ae3f29c45a6524b436e65a402495eff77f
parent84a0da6af95dd12393f5afcdafba747a9b8879de (diff)
downloadzsh-9b33f07e10ae7d8e7974a1f9bd095273a1eb3996.tar.gz
zsh-9b33f07e10ae7d8e7974a1f9bd095273a1eb3996.tar.xz
zsh-9b33f07e10ae7d8e7974a1f9bd095273a1eb3996.zip
zsh-users/12008: Assert zsh emulation to avoid setopt problems; don't try
to run precmd or preexec if they don't exist.
-rw-r--r--Functions/Prompts/promptinit7
1 files changed, 5 insertions, 2 deletions
diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit
index 37e437699..031947893 100644
--- a/Functions/Prompts/promptinit
+++ b/Functions/Prompts/promptinit
@@ -39,6 +39,7 @@ promptinit () {
 }
 
 prompt_preview_safely() {
+  emulate -L zsh
   print $reset_color
   if [[ -z "$prompt_themes[(r)$1]" ]]; then
     print "Unknown theme: $1"
@@ -165,6 +166,7 @@ Use prompt -h <theme> for help on specific themes.'
 }
 
 prompt () {
+  emulate -L zsh
   local prompt_opts
   
   set_prompt "$@"
@@ -176,6 +178,7 @@ prompt () {
 }
 
 prompt_preview_theme () {
+  emulate -L zsh
   local -a psv; psv=($psvar); local -a +h psvar; psvar=($psv) # Ick
   local +h PS1=$PS1 PS2=$PS2 PS3=$PS3 PS4=$PS4 RPS1=$RPS1
   trap "${$(functions precmd):-:} ; ${$(functions preexec):-:}" 0
@@ -184,10 +187,10 @@ prompt_preview_theme () {
   (( $#* > 1 )) && print -n " with parameters \`$*[2,-1]'"
   print ":"
   prompt_${1}_setup "$@[2,-1]"
-  precmd
+  typeset +f precmd >&- && precmd
   [[ -o promptcr ]] && print -n $'\r'; :
   print -P "${PS1}command arg1 arg2 ... argn"
-  preexec
+  typeset +f preexec >&- && preexec
 }
 
 [[ -o kshautoload ]] || promptinit "$@"