Does anybody know why bash still has history substitution enabled by default? My .bashrc
has included set +H
for many many years but some other people are still getting bitten by this feature.
Given that pretty much everybody are using terminals with copy-paste features and bash compiled with readline
library and history substitution is enabled by default only in interactive shells, is there really any reason to have the feature at all? None of the existing scripts would be broken even if this was disabled by default for all shells.
Try this if you do not know why history substitution is broken:
$ set +H # disable feature history substitution
$ echo "WTF???!?!!?"
WTF???!?!!?
$ set -H # enable feature history substitution
$ echo "WTF???!?!!?"
echo WTF???echo WTF???!?!!?
WTF???echo WTF???!?!!?
(Clearly the feature has major issues if it's disabled by default for all scripting and a feature exists to verify the results before executing: shopt -s histverify
.)
See also:
ls -l foo/bar/baz/weeble.cpp
withless !$
than recall the command and edit it.&
? Why should I need to escape or quote a filename containing a?
? There are UIs for people who think this is a problem.!$
several times a day, and!!
quite often as well. I have to admit I don't use other history substitutions as much, but I would definitely be unhappy if the default behaviour of the shell I have been using for years suddenly changed.