How can I save/merge tcsh history without messing up history numbers?

57 Views Asked by At

For some reason, when saving and merging tcsh history after executing history -S or history -M, the history numbering jumps by the number of commands saved in the history file. It increases for each execution of history save command.

Pertinent .tcshrc lines:

set histdup=erase
set history=3000
set histfile=~/.tcsh_history
set savehist=( $history "merge" )

Is this a longstanding tcsh bug or am I doing something wrong?

~ > history | head
  2149  21:35   mv RSQE.iso RSQE\  ( 1 ) .iso
  2150  21:35   mv RSQE.iso RSQE\  \(1\).iso
  2151  21:35   mv RSQE.iso RSQE\ \(1\).iso
  2152  21:36   echo RSQE*
~ > history -S
~ > history | head
  4296  21:35   mv RSQE.iso RSQE\  ( 1 ) .iso
  4297  21:35   mv RSQE.iso RSQE\  \(1\).iso
  4298  21:35   mv RSQE.iso RSQE\ \(1\).iso
  4299  21:36   echo RSQE*
~ > history -M
~ > history | head
  6442  21:35   mv RSQE.iso RSQE\  ( 1 ) .iso
  6443  21:35   mv RSQE.iso RSQE\  \(1\).iso
  6444  21:35   mv RSQE.iso RSQE\ \(1\).iso
  6445  21:36   echo RSQE*
1

There are 1 best solutions below

0
Jeff Axelrod On

This seems to be a bug with merging history files when histdup is set to erase. Unsetting it and/or setting it to prev or all avoids this problem.

~ > unset histdup
~ > history -M
~ > history | head -4
  8594  21:35   mv RSQE.iso RSQE\  ( 1 ) .iso
  8595  21:35   mv RSQE.iso RSQE\  \(1\).iso
  8596  21:35   mv RSQE.iso RSQE\ \(1\).iso
  8597  21:36   echo RSQE*
~ > history -M
~ > history | head -4
  8594  21:35   mv RSQE.iso RSQE\  ( 1 ) .iso
  8595  21:35   mv RSQE.iso RSQE\  \(1\).iso
  8596  21:35   mv RSQE.iso RSQE\ \(1\).iso
  8597  21:36   echo RSQE*