Date:        Fri, 12 Jun 2026 10:35:01 +0200
    From:        Egmont Koblinger <[email protected]>
    Message-ID:  
<cagwczkl+9v25x2gzwox2mpketov_2tkddjl1zwxxtq1y6wi...@mail.gmail.com>

  | As someone who wants to create a pre-set PS0 for our users, it already
  | means I need to develop and test the value against at least 4 possible
  | different setups.

No you don't, if that is your actual objective.  PS0 is simply expanded,
and sent to the terminal -- if you want to be able to work without the
promotvars option enabled, which I wouldn't bother with, then you need to
also find a solution which requires no variable expansions (etc) at output
time.

It has been pointed out that the real problem is allowing users to append
their own string to your PS0, and that as your string might end in a \
that can cause a problem if the user's string starts with something which
that \ might combine with or affect in some way.

The solution to that is trivial, since it is "your users" who will be
using this thing, which I take to mean users of the vte terminal emulator.

That is, simply do not end the string you provide with a \.   Problem solved.

Note, that doesn't mean omitting the \, it means not ending at that point.
I gather you've been attempting to do that using \[ or \] or both - that's
the wrong way.   Simply append some character that vte will do nothing with
when it receives it (and for bash, don't use \1 or \2).   If you want enclose
that character in \[ \] so if your string is used for PS1 or PS2 it will
still work properly, for PS0 though that's not needed (but harmless as
the \[ and \] simply vanish there.   But it is your additional character
which is protecting the \ from being combined with what follows, not the
bash markers or anything they might generate.

I'd suggest a zero-width space character, if you do anything other than
ignoring one of those when received, I'd be surprised.  But anything you'd
ignore will do (what do you do with a received \6 (ascii ack) ?).

kre

Reply via email to