bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving command history for non-interactive shell


From: Chet Ramey
Subject: Re: Saving command history for non-interactive shell
Date: Mon, 19 Mar 2012 19:34:51 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

On 3/19/12 8:39 AM, Greg Wooledge wrote:
> On Fri, Mar 16, 2012 at 06:15:35PM -0400, Chet Ramey wrote:

>> Turn on history with `set -o history' and set HISTFILE and HISTSIZE as you
>> like.  You can probably set some of the right variables in .ssh/environment
>> and set BASH_ENV to a file that will run the commands you want.
> 
> The problem is, that doesn't actually work.
> 
> imadev:~$ ssh localhost bash <<'EOF'                                          
>   > set -o history
>> HISTFILE=~/.bash_history
>> HISTFILESIZE=500
>> echo hello world
>> EOF
> address@hidden's password: 
> hello world
> imadev:~$ tail -2 .bash_history
> rm statistical.tcl.rej 
> less sched.tcl.rej 
> 
> I blame this part of the documentation, although perhaps I should be
> looking at the code instead:
> 
>   When an interactive shell exits, the last $HISTSIZE lines
>   are copied from the history list to $HISTFILE.
> 
> I read that as "the HISTFILE doesn't get updated when a NON-interactive
> shell exits".

The documentation is correct.  Whether the code should be changed is a
different discussion.  Saving the history to $HISTFILE in any shell where
HISTFILE is set and history is enabled would certainly have made this
easier to solve.

Chet
-- 
``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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]