1

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.

Zike
  • 11
  • 1

2 Answers2

1

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.

ott--
  • 1,091
  • 1
  • 11
  • 13
1

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.

Zike
  • 11
  • 1
  • ${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 08:17