Wandering Thoughts archives

2017-01-22

An Ubuntu default Bash setup that irritates me, especially for root

Bash itself has a number of option settings to limit what it puts into the (interactive) command history list, such as $HISTCONTROL and $HISTIGNORE. A stock, no-startup-file Bash shell does not set any of them and so saves everything into the history list. However, many systems give you a default .bashrc file that sets some options here. In particular, Ubuntu has a very irritating default: it enables the ignorespace option in both /etc/skel/.bashrc and /root/.bashrc.

What ignorespace does, for people who have never encountered this, is that if your bash command line starts with a space character (and perhaps any whitespace), it will not be saved into the history list. No access through cursor up, reverse search, anything; it's as if you didn't run the command. Now, I'm sure that there are people and situations where this makes sense, but I believe strongly that it's a bad default and in particular it's very annoying to have as a default for root.

You might ask why this is the case. Well, suppose you have a recipe with steps that look like this:

  • install Exim4 and related packages:
    apt-get install gnutls-bin swaks unrar
    apt-get install exim4-daemon-heavy exim4-doc-info exim4-doc-html exim4
    

When you're going through this recipe, the natural way to execute things is to cut and paste the entire line from the recipe into a (root) window on the machine you're installing or doing something to. This means that the lines you're pasting in will start with whitespace and will not be saved in history. Did you get interrupted and want to quickly cursor-up to see what the last command you ran was? You can't. Do you want to look in .bash_history later to see which version of the install instructions you used, as reflected in the commands? You can't.

(This is the format our build instructions are in, so this particularly gets my goat.)

There are other situations where you can be cutting and pasting things into sessions and include even a single space at the start, which will have the same effects. For that matter, you can be editing previous commands in a way that leaves a space at the start and again, the same thing happens. In my opinion, it ought to be a lot harder than this to exclude things from history.

(Having written this entry, I should go change our standard install stuff so it sets up a /root/.bashrc that has this removed. I don't think any of us will miss it; rather the reverse, probably.)

PS: I don't have a Debian system handy to check, but it's possible that this is a default that Ubuntu inherited from Debian instead of something that they decided on their own.

(Some searching turned up this bug-bash thread on why HISTCONTROL=ignorespace exists as an option (via). Debian or Ubuntu may have decided that this is an important enough usage case to make it a default. If so, I disagree.)

linux/UbuntuBashIgnorespaceIrritation written at 02:24:10; Add Comment


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.