zsh interpret some %[a-z] in command line

Bug #435336 reported by Pierre Chef
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
zsh (Ubuntu)
Invalid
Low
Unassigned

Bug Description

Binary package hint: zsh

On command line, zsh interprets some %<letter> without possibility to escape it.
It is especially a problem with date which uses % in its format.

zsh /tmp$ date "+%d/%m %kh%M"
]0;date "+/tmp/ubuntu hubuntu"23/09 17h15

bash /tmp$ date "+%d/%m %kh%M"
23/09 17h15

This bug only appears on command line, not in script or when you pipe commands
zsh /tmp$ date "+%d/%m %kh%M" | less
will show the good result in less.

zsh 4.3.9-4ubuntu1
bash 3.2-5ubuntu1
coreutils 6.10-6ubuntu1

Revision history for this message
Pierre Chef (pierre.chef) wrote :

In fact, it is due to this line in prexec used to put the current command in the terminal title.
preexec() {
             print -Pn "\e]0;$1\a"
        }

I found this information here https://bbs.archlinux.org/viewtopic.php?id=107834

Revision history for this message
Daniel Hahler (blueyed) wrote :

This preexec does not get shipped with Ubuntu, does it?

You might want to escape it using $'', like:
   print -Pn $'\e]0;$1\a'

See also the "print"'s in the title() function of my oh-my-zsh fork at:
https://github.com/blueyed/oh-my-zsh/blob/8d5105135772ae0c3c81850cea422cc322ed6f7d/lib/termsupport.zsh#L27

Changed in zsh (Ubuntu):
importance: Undecided → Low
status: New → Incomplete
status: Incomplete → Invalid
Revision history for this message
kk_hephot (ksk) wrote :

According to the post here: <https://bbs.archlinux.org/viewtopic.php?id=107834> you simply need to amend $1 to ${~1:gs/%/%%}. That works for me.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.