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    [email protected]    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to