Re: PS0 vs. \[ \] followup
Chet Ramey <[email protected]> Wed, 10 Jun 2026 12:15:51 -0400
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Organization | ITS, Case Western Reserve University |
| Message-ID | <[email protected]> |
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/
OpenPGP_signature.asc
(application/pgp-signature, 203 B)
-----BEGIN PGP SIGNATURE----- wmMEABEIACMWIQR8ATX7CIqvbGbGULm7WGnwZOp0qwUCaimNtwUDAAAAAAAKCRC7WGnwZOp0q+6O AJ9e9niQJOcCGNoRBrUVX2/tpWIOfACeMdizUsCxNYEj8lT7CBCjPDYKW78= =TAsf -----END PGP SIGNATURE-----