bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PS0 vs. \[ \] followup


From: Chet Ramey
Subject: Re: PS0 vs. \[ \] followup
Date: Wed, 10 Jun 2026 12:15:51 -0400
User-agent: Mozilla Thunderbird

On 6/9/26 3:40 PM, Robert Elz wrote:

   | $ PS4='+\[$\]-'
   | $ set -x
   | $ echo hello
   | +$- echo hello
   | hello

If that's what you're trying to achieve, then

        PS4='+\$-'

will do it, and what's more, work the same way in PSn (for any n), and
whether or not line editing is enabled.

Not quite, since \$ is a valid prompt expansion escape sequence, but you
can make it work.

As I understand the bash rules, between the \[ and \] in prompts there
are only supposed to be data which affects the display mode of the
terminal (change colour, bold, blinking, ...) and do not cause any
actual visible output.   If you have a '$' there (alone) then that breaks
the rules, and I think anything is reasonable as a result.

This is true, even if the documentation is not quite explicit that these
sequences are not useful in any other context.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]