Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-Id: <199905221202.FAA05824@shell4.ba.best.com> Subject: Re: bash history not restored In-Reply-To: <37458F00.C8D1FD58@lbin.com> from Ian Zimmerman at "May 21, 99 09:51:12 am" To: cygwin AT sourceware DOT cygnus DOT com Date: Sat, 22 May 1999 08:02:29 -0400 (EDT) From: Glenn Spell Reply-To: glenn AT gs DOT fay DOT nc DOT us (Glenn Spell) Organization: the aerie X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: . Please let me know if this helps. Thanks. -glenn -- ) Glenn Spell ) _ _____ ) 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 AT sourceware DOT cygnus DOT com