|
From: | Chet Ramey |
Subject: | Re: BASH_COMMAND should be set before PS0 |
Date: | Mon, 21 Mar 2022 09:34:30 -0400 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 |
Bash Version: 5.1 Patch Level: 16 Release Status: release Description: PS0: The value of this parameter is expanded like PS1 and displayed by interactive shells after reading a command and before the command is executed. BASH_COMMAND: The command currently being executed or about to be executed, unless the shell is executing a command as the result of a trap, in which case it is the command executing at the time of the trap. If BASH_COMMAND is unset, it loses its special properties, even if it is subsequently reset. PROBLEM: By the time PS0 is displayed, BASH_COMMAND is still set to the previous command, not the command about to be executed.
These two events take place at different points in command processing. PS0 is displayed immediately after the shell reads a command. BASH_COMMAND is set after assignment statements and redirections are processed as part of command execution. You can't reconcile these two things. -- ``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/
[Prev in Thread] | Current Thread | [Next in Thread] |