Wandering Thoughts: Recent Entries For 2008/03/12

Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web.

2008-03-12

A bash irritation: mutable history

Here's one of those little things that irritate me about bash, or more specifically its command line editing: its command history is (sometimes) mutable. Under at least some circumstances, you can overwrite a command that is in your history by going back to it (with search or cursor up) and editing it again. When you do this, the old version of the command is gone permanently; if you cursor back to it again, you see your freshly edited version.

(This doesn't seem to happen all of the time or on all of the machines I use bash on. So far I haven't had the patience to track down exactly what's going on.)

My mental model of shell history is that the past is immutable because it is, after all, the past; editing a past command should just result in a new command that just looks a lot like the old one. To have a sometimes mutable command history makes me nervous and twitchy; among other things, that old command may be the only version where I had something working (and I am editing it to try to improve things, which may or may not be successful).

I do have some sympathies with the mutable command history crowd. If you think of the command history as basically an edit buffer, it's more natural to change things in place, and even if you don't there are a bunch of interesting decisions (and painful programming) to do to make things come out right.

(Thinking about some torture test scenarios, I think you need to pretend that you have a mutable edit buffer and then undo all of the mutations at certain trigger events and insert any new command line at the end of the history. I maintain that one such trigger event should be clearing the entire line, however it happens.)

unix/MutableBashHistory written at 23:47:12; Add Comment

These are my WanderingThoughts
(About the blog)

GettingAround
Full index of entries
Recent comments

This is part of CSpace, and is written by ChrisSiebenmann.
Twitter: @thatcks

* * *

Atom feeds are available; see the bottom of most pages.

This is a DWiki.
(Help)

Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web

Search:
By day for March 2008: 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31; before March; after March.

Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.