Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16800
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: How to use PROMPT_COMMAND(S) without breaking other scripts |
| Date | 2020-08-24 10:57 -0400 |
| Organization | ITS, Case Western Reserve University |
| Message-ID | <mailman.997.1598281085.2469.bug-bash@gnu.org> (permalink) |
| References | <CAKOZuevPZ1xwhLmLzXt_a=G+azDTouO52MCA=wvh=-M82wzaSQ@mail.gmail.com> <17a0ba52-32ee-b9bc-72ff-3587b2050fbd@case.edu> <CAFLRLk9vNPM5NtypB2UNcDqMZfG3Lmi3zEMGfPqZNacmHCoAoA@mail.gmail.com> <0c10b76f-a7f0-1c52-77b7-4b208035956b@case.edu> |
On 8/22/20 10:35 PM, Koichi Murase wrote: > Hi, I have a question on the behavior of the new array PROMPT_COMMANDS > and the best practice to use it. > > In coming Bash 5.1, the new array variable `PROMPT_COMMANDS' is > available in the replacement of `PROMPT_COMMAND'. When the array > `PROMPT_COMMANDS' has one or more elements, the scalar version > `PROMPT_COMMAND' is disabled. > > Is there a background that the scalar version is disabled in the > presence of the array version? There's no real good solution. I wanted a clean break between the scalar and array versions, figuring that the distributions that populated PROMPT_COMMAND could easily make that PROMPT_COMMANDS[0]. It would be easy enough to favor PROMPT_COMMANDS over PROMPT_COMMAND, but execute both if both are set. The problem there is that it interferes with the ability to use both, as some distros might want as a transition, and result in commands being executed twice. Since you have to check the bash version to make sure that PROMPT_COMMANDS is going to work, I don't think it's going to be that hard to use one or the other consistently. I sometimes think I should have stuck with converting PROMPT_COMMAND to an array. Either way, there's going to be a transition, and maybe that would have been the easiest. -- ``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/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: How to use PROMPT_COMMAND(S) without breaking other scripts Chet Ramey <chet.ramey@case.edu> - 2020-08-24 10:57 -0400
csiph-web