bash history not restored

Glenn Spell glenn@gs.fay.nc.us
Mon May 31 21:10:00 GMT 1999


Ian Zimmerman wrote:

> > > Ian Zimmerman wrote:
> > >
> > > > No matter what I do, I can't seem to make bash restore the
> > > > command history from .bash_history when it starts.

For me, Cygwin Bash 2.02 and 2.03 need to start up with a history
file written in Unix format... although, Cygwin Bash usually writes
the file in Windows/DOS format. I say "usually" because I have seen
the history file end up in Unix format after Bash closes.  If I write
it out from within Bash, it's always in Windows/DOS format.

Also, on some occasions, there will be additional lone carriage
returns added to the end of lines in the history file... just
carriage returns with no linefeeds (but there's still a linefeed on
the very end). These show up as blank lines in PFE (Programmer's File
Editor) and as control characters in Notepad. In Bash, they show up
as extra "^M" characters tacked on the end of history command lines.

I'm not sure but these lone CRs (and possibly the occasional Unix
formatting) seem to happen when the history file is written from
memory to disk after Bash has closed. I suspect this is a bug in
Cygwin.

I suspect the writing-in-DOS-format and reading-in-Unix-format is
a porting issue, although that too may be a bug in Cygwin. I tried
changing all opens in the Bash source file "lib/readline/histfile.c"
to "O_TEXT", but that didn't seem to help any at all.

> > > > Running Cygwin-b20.1, NT Workstation SP4, FAT fs, text mount.

I'm running B20.1, Win95B, text mounts, only text mounts, and
nobinmode.  I don't know how the following will apply to WinNT.

> So, HOW do I make history work AND have text opens/fopens by
> default?

Here's an excerpt of my ".bashrc" file that shows how I do it.

flip -u ~/.bash_history
mv ~/.bash_history ~/.bash_histemp
sed '/^$/d' ~/.bash_histemp > ~/.bash_history
rm ~/.bash_histemp
flip -u ~/.bash_history

The first 'flip -u' removes the lone CRs. The Flip documentation
states that 'flip -u' will leave lone CRs unchanged, but that's not
the case with my Cygwin port.

The 'mv' and 'rm' are there because I'm set up so that 'sed' cannot
overwrite an existing file.

The 'sed' command removes any remaining blank lines because these too
would show up in Bash as "^M" characters.  Cygwin Sed writes the file
in Windows/DOS format.

The final 'flip -u' converts the file back to Unix format.

A precompiled Flip with documentation is available at:
< http://www.fay.nc.us/~glenn/cygwin/ >.

Please let me know if this helps. Thanks.

-glenn

-- 
 )      Glenn Spell <glenn@gs.fay.nc.us>      )   _       _____
 )   Fayetteville, North Carolina, C. S. A.   )_ (__\____o /_/_ |
 )  _  _  _  _  _  _  _  _  _  _  _  _  _  _  )   >-----._/_/__]>
 )- blue skies - happy trails - sweet dreams -)             `0  |

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list