[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use PROMPT_COMMAND(S) without breaking other scripts

From: Chet Ramey
Subject: Re: How to use PROMPT_COMMAND(S) without breaking other scripts
Date: Mon, 24 Aug 2020 10:57:54 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

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

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/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]