Some instances of bash change the command history when you re-use and edit a previous command, others apparently don't. I've been searching and searching but can't find anything that says how to prevent commands in the history from being modified when they're reused and edited.
There are questions like this one, but that seems to say how to cope with the history being edited. I've only recently come across an instance of bash that does edit the history when you reuse a command - all previous bash shells I've used have (as far as I've noticed) been configured not to change the history when you reuse and edit a command. (Perhaps I've just not been paying proper attention to my shell history for the past 15 years or so...)
So that's probably the best question: CAN I tell bash NEVER to modify the history - and if so, how?
history -pto do history expansions without affecting the history file. You can dohistory -sto do same and appending to history without execution. You can doHISTIGNORE='start of a command I never want in history.*:command2.*'to keep certain commands out of history. – mikeserv Sep 10 '14 at 10:47set revert-all-at-newline onin the question you link solve your problem? Can you show how to reproduce the problem? Note that you can also usezshfor a behaviour more inline with what you want. – Stéphane Chazelas Sep 10 '14 at 11:03history -pis something I would have to do for every command that I want to reuse - is that right? If so, that's not quite what I'm looking for. As I mentioned, I've used instances of bash that don't ever modify the history when a command is reused and edited. – IpsRich Sep 11 '14 at 12:21revert-all-at-newlineis quite what I need. If I edit a command and press CTRL-C to cancel it, I also don't want that to affect the history. I've never before had to configure bash not to modify the history, which is part of the reason I'm confused as to why sometimes a fresh install behaves in one way and sometimes in the other. By the way, on an instance that does not edit the history on command reuse, abind -V | grep revertindicates thatrevert-all-at-newlineis set to 'off'. – IpsRich Sep 11 '14 at 12:25bashin the past. – Stéphane Chazelas Sep 11 '14 at 12:34bashkinda sucks. As shells go, you could do much better -bash's history handling is especially pretty much insane. Anyway, there is also the$HISTCONTROLvariable which accepts variousshoptvalues and the concept of a history comment character. You might also look at the myriadcompvxxshoptsettings to see if one matches the behavior you've grown used to. – mikeserv Sep 11 '14 at 13:11zshis the popular choice, but that way lies a tangled-knot of incompatibility (though it is still one I use on a daily basis).ksh93is kind of amazing - though some people find the prompting difficult to get used to (not too hard to handle actually and another daily driver here). Anddashis crazy fast, generally compliant in every way, and eminently configurable, but you will likely want to compile it yourself w/ thelibeditbuild-time option (I'm 3-car-a-day kind of guy I guess). Mostly I regardbash'sreadlinean interactive nightmare. – mikeserv Dec 09 '14 at 18:20ksha try. – Agi Hammerthief Dec 10 '14 at 11:09bash. It's all about readline. There are different implementations ofreadlinelibrary, and it also has its own set of settings (A LOT of them) and its own configuration file. I'm not sure exactly if this is a setting or simply an implementation difference, but you should search in readline-related documentation, not bash. – orion Jan 23 '15 at 10:14revert-all-at-newlinemay have something to do with this after all: there's another thread that claims this was the answer. However, when I turnrevert-all-at-newlineoff it has no obvious effect: it does not suddenly enable me to edit my history! So there has to be something else somewhere that also needs to be changed. – IpsRich Nov 11 '15 at 13:15revert-all-at-newlinetoonand yes, it worked! Now, there are no asterisks in my history and nothing gets changed therein. The only thing I have noticed is that you can't doset revert-all-at-newline onon the command line: it has to be in~/.inputrcfor it to take effect. – IpsRich Aug 01 '16 at 09:05