Skip to content
This repository

termsupport.zsh: unwanted execution of commands; interpretation of %-tags [PATCH] #890

Closed
tomterl opened this Issue · 4 comments

4 participants

Tom Regner Robby Russell Sorin Ionescu François Saint-Jacques
Tom Regner

termuspport.zsh will execute subcommands on the current commandline; the output will be garbled due to prompt expansion of %-tags in commands like date/printf.

Please apply the following patch:


*** termsupport.zsh.orig    2012-01-31 10:49:57.503119973 +0100
--- termsupport.zsh 2012-01-31 10:50:55.043118110 +0100
***************
*** 24,31 ****
  function omz_termsupport_preexec {
    emulate -L zsh
    setopt extended_glob
!   local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
!   title "$CMD" "%100>...>$2%<<"
  }

  autoload -U add-zsh-hook
--- 24,35 ----
  function omz_termsupport_preexec {
    emulate -L zsh
    setopt extended_glob
!   local CMD_1=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
!   local CMD_2=${2//\$\(/\\\$(} # ')}
!   CMD_1=${CMD_1//\%/%%}          
!   CMD_2=${CMD_2//\%/%%}          
!   #
!   title "${CMD_1}" "%100>...>${CMD_2}%<<"
  }

  autoload -U add-zsh-hook

It might be necessary to escape backticks also, but I don't use these...

kind regards,
Tom

Sorin Ionescu

I had problems with this myself. I rewrote the terminal support in my fork in relation to #377.

François Saint-Jacques

This is disastrous, please apply the patch ASAP. Let's say I have a command that modifies his state at each call. The normal behaviour would look like this.

$ echo 1 > herp
$ echo $(cat herp | tee -a herp)
1
$ echo $(cat herp | tee -a herp)
1 1
$ echo $(cat herp | tee -a herp)
1 1 1 1

With the current oh-my-zsh version you get:

$ echo 1 > herp
$ echo $(cat herp | tee -a herp)
1 1
$ echo $(cat herp | tee -a herp)
1 1 1 1 1 1 1 1
$ echo $(cat herp | tee -a herp)
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

tomterl's patch fixes the issue.

Robby Russell robbyrussell closed this
Robby Russell
Owner

Closing this per #2568.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.