Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

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

2 Answers 2

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.

share|improve this answer

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.

share|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 '12 at 8:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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