Re: ="${!a[@]}" expands incorrectly bash 5.1 and above + patch
Chet Ramey <[email protected]> Fri, 29 May 2026 16:53:01 -0400
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Organization | ITS, Case Western Reserve University |
| Message-ID | <[email protected]> |
On 5/24/26 5:31 AM, Emanuele Torre wrote: > The current order of these cases does not seem logical to me; it is > probably incorrect: I would expect the PF_ASSIGNRHS case not to care > about whether the expansion is quoted, and thus also to take precedence > over the case for double quoted expansions outside of assignments. Thanks for the report. The question is consistency: does quoted $@ in a context where word splitting doesn't take place behave the same as unquoted $@, or does it behave like quoted $*? (This only makes a difference when IFS is not the default, so it's a niche case.) There was a pretty decent discussion about this in the replies to your message from last November that you reference later; kre points out that the behavior of all of this is unspecified, and there are two camps, one for each interpretation. > Unless I am missing something, reordering those two cases seems to fix > the regression; so, the fix probably looks similar to something like > this: You didn't run the test suite, did you. Anyway, I agree with you: it's better to have consistent behavior between quoted and unquoted $@ in a context where word splitting doesn't take place, than to have quoted $@ and $* behave the same. 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----- wmMEABEIACMWIQR8ATX7CIqvbGbGULm7WGnwZOp0qwUCahn8rQUDAAAAAAAKCRC7WGnwZOp0qyfq AJ4lD0cju+PghatBkAN0kQNpXUUnHACgjJTA17bwaAZ7LfYcOTbPtB8Rh1I= =js6E -----END PGP SIGNATURE-----