View Single Post
Posts: 268 | Thanked: 1,053 times | Joined on May 2010 @ The Netherlands
#242
Originally Posted by ivgalvez View Post
I have again lost my history. Now there is no garbage in files but I couldn't trigger any command pressing CTRL+R.

I have checked that file .ash_history is empty. There is also a file .ash_history.1918.new that is empty and a ash_history.3055.new with only 100 very old commands.
Hmm, that's real unfortunate news to hear.

When you close ash, it'll append all of its new history to .ash_history, completely re-load .ash_history (other instances of ash might have written to it, and re-loading trims it to MAX_HISTORY), write the trimmed history out to .ash_history.$PID.new, and rename .ash_history.$PID.new to .ash_history.

The used code for this is pretty solid (look for save_history() in libbb/lineedit.c), and I don't see any direct cause as to why you lost your history . The only clue we have is that rename() somehow failed, since you still got .ash_history.XXXX.new files. It's rather odd though that you experienced this twice - the only other report is from Mentalist Traceur, but he mentioned that the device was unstable.

You could add something like the following to your ~/.profile file. This will backup your old history to /home/user/hist_bak/ when you close ash. It won't solve the issue you're experiencing, but at least you won't lose all of your history. I'm sorry I can't be of more help.
Code:
trap 'NAME=`date +%Y%m%d_%H%M%S`_bak && \
  cp /home/user/.ash_history /home/user/hist_bak/$NAME' 0

Last edited by iDont; 2012-03-06 at 22:27.
 

The Following 2 Users Say Thank You to iDont For This Useful Post: