Re: PS0 vs. \[ \] followup

Chet Ramey <[email protected]> Fri, 12 Jun 2026 12:58:00 -0400
Newsgroups gmane.comp.shells.bash.bugs
Organization ITS, Case Western Reserve University
Message-ID <[email protected]>
On 6/10/26 6:21 PM, Koichi Murase wrote:

>> I can agree that the current behavior is one possible consistent
>> behavior, but could you take this as ``a feature request'' for another
>> consistent behavior? That is, the removal of \x01 and \x02 is
>> performed at the very last stage so that the behavior of the
>> `promptvars' processing of PS0 and PS4 is unaffected.

I responded to this in a subsequent message. I didn't really respond here
because the request represents a fundamental misunderstanding about
how \[ and \] work, and where the \1 and \2 markers are `removed',
and what you really want is some dummy separator character you can use at
the end of the supplied PS0.


>>
>> If you think it is not consistent with `the --noediting PS1', I think
>> one can switch the behavior depending on `--noediting'. If line
>> editing is disabled, \[\] may produce an empty string from the
>> beginning. Otherwise, \[ and \] produce \x01 and \x02, which will
>> later be properly processed or removed at the final stage. 

I don't think adding new code to strip \1 and \2 from prompt strings that
aren't going to be passed to readline is a useful addition.

-- 
``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-----

wmMEABEIACMWIQR8ATX7CIqvbGbGULm7WGnwZOp0qwUCaiw6mQUDAAAAAAAKCRC7WGnwZOp0q/ek
AJ0fTO5irOmZNi+t7QJUwsGw7i9xtQCgmH098lCTf4Gj9DBG9lqfwtFPaSE=
=2QRU
-----END PGP SIGNATURE-----