On Wed, May 19, 2004 at 10:37:50PM +0100, Peter Stephenson wrote: > Probably allowing it with both would be better, since `history' is a more > natural command. I agree that the command name reads better, but since it has always implied listing of history entries, it seems a little weird to change that. I went ahead and added the -p & -P options to the history builtin, but I didn't document it yet. > Looks essentially OK to me as it is, it can be enhanced later if we > feel like it. OK, I checked it in. I also started to work on an auto-pop feature from a function. Attached is a patch that almost works right, but has a couple areas that need to be improved. Perhaps someone can chime in here with some advice on how to either do this the right way or fix the problems. I chose to add my pop-checking hook into level() -- the routine that decrements locallevel. One problem I encountered is that this routine is called on function exit _before_ the traps are run. This means that if someone puts a manual "fc -P" call into a trap, it will try to do an extra pop after the auto-pop for leaving the function. I suppose we can just tell people not to do that... The other problem I noticed is how the saving of the parameters interacts with local variables. Take these two functions for instance: function foo { local HISTSIZE=2221 fc -p ~/.newhist 2222 2222 echo $HISTFILE $HISTSIZE } function bar { fc -p local HISTFILE=~/.newhist HISTSIZE=2223 echo $HISTFILE $HISTSIZE } In function foo the history-list push saves off the 2221 from the local variable, so we have to be sure to call the history-list pop function before removing the local variables (which is what I currently do). However, in function bar the history-list push saves off the global value of the HISTFILE and HISTSIZE variables, which are then made local. When the function exits, the history-list pop first restores the global values of the variables to the environment, and then the local-variable restoration unsets HISTFILE and makes HISTSIZE=30 (the default value). Is this something we can easily fix? Perhaps with a different way of saving the environment values? Or is this something where we tell users that they can't both use "fc -p" and make the variables local? ..wayne..