help / color / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: What's wrong with PROMPT_SUBST? (Was: VCS info (Re: Call for good plugins list))
Date: Wed, 12 Feb 2020 08:17:56 +0100
Message-ID: <CAHYJk3QDAYMDZeCmSNPq8rhSb5bZze7iZc0AtBXQ7QhUVNcBpQ@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7Z1yjRLWUCSr4VTSR0OEkmwEFwaz7Dy237ha4P1Ov05=w@mail.gmail.com>

On 2/12/20, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Tue, Feb 11, 2020 at 1:38 AM Lawrence Velázquez <vq@larryv.me> wrote:
>> > On Oct 1, 2017, at 5:50 PM, Bart Schaefer <schaefer@brasslantern.com>
>> > wrote:
>> >
>> > The main thing is that I despise prompt_subst
>> Why is that?
> Mostly it's a matter of taste.  It introduces yet another set of
> tokens that you have to escape to use literally in prompts, and I
> don't think the prompt is an appropriate place to be running command
> substitutions.  It means even more possible collisions on variable
> names with unintended side-effects.   Obviously these are things that
> can be avoided; I'd just rather not have to think about them.

One particular cargo culted piece of setup is the following combo,

setopt prompt_subst
preexec() {
  print -P "$escape_to_set_terminal_title $1 $end_terminal_title"

which will result in the following command having funny results,
echo '$(killall -9 zsh)'

(the above code is wrong even without prompt_subst but the
consequences are quite a bit worse with it). The easy fix with
prompt_subst enabled is to use \$1 instead which should be more or
less fine as long as you haven't literally typed in the
$end_terminal_title code.

Mikael Magnusson

      reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-01 16:23 Call for good plugins list Sebastian Gniazdowski
2017-10-01 16:41 ` Ray Andrews
2017-10-01 18:54   ` Bart Schaefer
2017-10-01 19:29     ` Daniel Shahaf
2017-10-01 21:50       ` VCS info (Re: Call for good plugins list) Bart Schaefer
2017-10-01 22:16         ` Daniel Shahaf
2020-02-11  9:38         ` What's wrong with PROMPT_SUBST? (Was: VCS info (Re: Call for good plugins list)) Lawrence Velázquez
2020-02-12  5:23           ` Bart Schaefer
2020-02-12  7:17             ` Mikael Magnusson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHYJk3QDAYMDZeCmSNPq8rhSb5bZze7iZc0AtBXQ7QhUVNcBpQ@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-users@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link


Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git