Bug 59613
Description
Roland Kaufmann
2002-02-11 09:35:58 UTC
Created attachment 45199 [details]
Patch against bash 2.05 to enable pre-execution hook
I've sent a message to the base package maintainers asking their opinion on this. I'm not sure about it myself, since there's both some good use (like what you're suggesting) and some potential for abuse and of course overhead. Waiting on feedback from base maintainers. I don't think that it is more prone to abuse than the PROMPT_COMMAND construct, except perhaps for that commands can be cancelled (which was intended as a feature). When it comes to overhead, SPAWN_COMMAND is only evaluated in interactive shells, and thus takes typically a lot less time to evaluate than the latency of the user. I have used it myself for three months now, and have never experienced it as interruptive of my work. Created attachment 61166 [details]
Stripped-down patch with minimum required functionality
I have created a new patch (against the version of bash that comes with RedHat 7.3), that only contains the around 10 lines of code that contains the minimum required functionality for the pre-execution hook to work. It gets rid of some ugly code to retrieve the last command-line, but instead relys on that history is enabled so that the user can set the variable like this: export SPAWN_COMMAND='echo -ne "\033]0;`history 1 | cut -c 8-` in ${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"' Created attachment 61245 [details]
Reduced patch (only 3 lines!); now equivalent to PROMPT_COMMAND
Created attachment 64104 [details]
Patch to enable SPAWN_COMMAND environment variable
Created attachment 64105 [details]
Patch to enable LASTCMD environment variable
The latest two patches give back most of the functionality of the original proposal. SPAWN_COMMAND is an environment variable understood by the shell in the same way as the PROMPT_COMMAND variable is already except that it is executed before instead of after the command. LASTCMD is an environment variable set by the shell in the same way as the HISTCMD variable except that it will contain the actual contents of the command line instead of its history number. These patches has been tested against RedHat Linux 7.3. Due to the appearant lack of interest in this functionality, further patches will not be posted to Bugzilla but to my website only. |