Skip to content

Commit

Permalink
zshrc: Reset $REPLY parameter before calling prompt token functions
Browse files Browse the repository at this point in the history
It may be tempting to write a prompt token function like this

    if (( ${+commands[kerl]} )) REPLY=$(kerl prompt '<%s> ')

But if the command does not exist user may be end up with duplicated
tokens in her prompt.  Resetting $REPLY parameter before calling
user-defined functions prevents this problem.
  • Loading branch information
dmitrivereshchagin committed Jun 22, 2019
1 parent ffe57c8 commit 03ec73c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions etc/zsh/zshrc
Expand Up @@ -2269,6 +2269,7 @@ grml_theme_add_token: Token `%s'\'' exists! Giving up!\n\n' $name
return 2
fi
if (( init )); then
REPLY=''
$token $name
token=$REPLY
fi
Expand Down Expand Up @@ -2314,6 +2315,7 @@ function grml_prompt_addto () {
zstyle -s ":prompt:${grmltheme}:${lr}:items:$it" token new \
|| new=${grml_prompt_token_default[$it]}
if (( ${+grml_prompt_token_function[$it]} )); then
REPLY=''
${grml_prompt_token_function[$it]} $it
else
case $it in
Expand Down

0 comments on commit 03ec73c

Please sign in to comment.