[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] `shopt -s histappend` vs `export PROMPT_COMMAND="history
Re: [Help-bash] `shopt -s histappend` vs `export PROMPT_COMMAND="history -a"`
Tue, 05 May 2015 15:21:52 -0400
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
On 5/2/15 11:32 PM, Peng Yu wrote:
> I see the following two ways to update the history file. Are they
> equivalent? Or they might be slightly different in some way?
> - `shopt -s histappend`
> - `export PROMPT_COMMAND="history -a"`
Well, of course they're different at a high level. One acts when the
history file gets written at the end of the shell session (usually), and
one appends `new' history entries before each command. They call the same
history function in the end, though.
> I have `shopt -s histappend` in ~/.bashrc in a machine whose home is
> on an nfs. But I frequently encounter hanging on history related
> commands upon long. (I have not got the time to try export
> PROMPT_COMMAND="history -a"`).
> Could `shopt -s histappend` cause NFS related problems?
It might, but when you get down to it, it just uses O_APPEND in the flags
the history writing code passes to open(2) instead of O_CREAT|O_TRUNC
(overwrite). Any problems that result from that change are probably not
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/