Path: csiph.com!fu-berlin.de!usenet.stanford.edu!not-for-mail From: Martijn Dekker Newsgroups: gnu.bash.bug Subject: Re: How to use PROMPT_COMMAND(S) without breaking other scripts Date: Mon, 24 Aug 2020 20:53:43 +0100 Lines: 38 Approved: bug-bash@gnu.org Message-ID: References: <17a0ba52-32ee-b9bc-72ff-3587b2050fbd@case.edu> <0c10b76f-a7f0-1c52-77b7-4b208035956b@case.edu> <669a0539-fd4f-b4f9-f4c5-06922fb670d0@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1598298833 13888 209.51.188.17 (24 Aug 2020 19:53:53 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 In-Reply-To: <669a0539-fd4f-b4f9-f4c5-06922fb670d0@case.edu> Content-Language: en-GB Received-SPF: none client-ip=2a02:2770::21a:4aff:fec6:e3d8; envelope-from=martijn@inlv.org; helo=freekahlil.inlv.org X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-2.25, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <17a0ba52-32ee-b9bc-72ff-3587b2050fbd@case.edu> <0c10b76f-a7f0-1c52-77b7-4b208035956b@case.edu> <669a0539-fd4f-b4f9-f4c5-06922fb670d0@case.edu> Xref: csiph.com gnu.bash.bug:16805 Op 24-08-20 om 20:37 schreef Chet Ramey: > On 8/24/20 12:58 PM, Martijn Dekker wrote: >> Op 24-08-20 om 15:57 schreef Chet Ramey: >>> 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. >> >> Is it too late? I think that would actually be cleaner than adding a >> separate array, per Koichi's report. > > We're not "adding" anything. Bash just looks for this variable and reacts > if it finds it. It's not a special variable, and bash doesn't create it if > it doesn't exist. So now you're adding code that looks for an array. Which is something other than nothing. Granted, my language wasn't very precise, but I'm fairly confident that my intent was understandable. > What I mean is looking for PROMPT_COMMAND as happens now, and reacting a > different way if it's an array variable. That would resolve the existing > assignment issues, but open up the separate issues you describe. But I also suggested a way of avoiding those issues: initialise $PROMPT_COMMAND a.k.a. ${PROMPT_COMMAND[0]} as empty. - M. -- || modernish -- harness the shell || https://github.com/modernish/modernish || || KornShell lives! || https://github.com/ksh93/ksh