does anyone have any idea why am I getting hit by this bug in zsh since forever? It's like a string formatting bug of some sorts:

~% printf "%s\n" foo

" foo)foo

Basically anything that has double quotes gets interpreted in a similar manner:

~% perl -e 'printf("%s\n", "foobar")'

", "foobar")')foobar

Zsh config isn't elaborate, just some basic things like:

setopt appendhistory histignorealldups autocd autopushd
bindkey -e
zstyle :compinstall filename '/home/zike/.zshrc'
autoload -Uz compinit
compinit

any hints why that can happen? Thanks.

link|improve this question
what does type -af printf show you? – glenn jackman Oct 18 '11 at 16:18
feedback

2 Answers

This works for me:

> printf "%s\n" foo
foo

What zsh version do you have on what system? I have zsh 4.3.10 on Linux.

link|improve this answer
feedback

ok. thanks for replies, i've finally unslacked and checked the config file again. this funny behavior is caused by ``preexec'' hook:

preexec () { print -Pn "\e]0;%m - %~ ($1)\a" }

$1 is expanded to the user input and zsh gets confused about format specifier (%s that is). i haven't found a way to properly sanitize the string, but tr -d % does the job. escaping % didn't help.

link|improve this answer
${1//%/_} but you may find this informative: printf '%s %s\n' ${(%):-'%n %m foo'} '%n %m bar' -- note that (%) causes the variable expansion to have prompt escape sequences expanded. So perhaps: preexec () { printf '\e]0;%s (%s)\a' ${(%):-'%m - %~'} "$1" } – Phil P Jan 14 at 8:17
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.