Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] local history support, take 2



Wayne Davison wrote:
> 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.

Is this going to be optional eventually?  It's a little confusing having
`fc -P' as well, otherwise.  You can use them as a pair at the command
line but I think it should be deliberate to select one behaviour or the
other.

You can also reject attempts to use `fc -P' if the history is marked for
automatic restoration which gets around the other problem.

> function bar {
>     fc -p
>     local HISTFILE=~/.newhist HISTSIZE=2223
>     echo $HISTFILE $HISTSIZE
> }
> 
> 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?

I think it needs to be documented that if you're using commands you
shouldn't touch the variables by hand, otherwise confusion like this is
inevitable.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author