On 2021-02-27 11:02:17 +0000, Axel Reichert said:
> bash also has them, but Korn and POSIX shells are lacking these
> features.
The Korn shell (i.e.: AT&T ksh93) has that feature, actually. Note that
mksh is not the Korn shell (as in David Korn's shell); it's a
derivative of pdksh which is an independently developed open-source
clone of an old closed-source generation of the Korn shell (ksh88).
Though mksh does add a few ksh93 features, and some mksh-specific ones.
Personally, I hate history expansion and turn it off, because it tends
to get in the way whenever you need an exclamation point for some other
purpose within double quotes, as in:
$ echo $BASH_VERSION; set -o histexpand
5.1.0(30)-rc2
$ echo "one!two"
bash: !two: event not found
$ echo "one\!two"
one\!two
$ echo $KSH_VERSION; set -o histexpand
Version AJM 93u+m/1.0.0-alpha+b48e5b33 2021-03-04
$ echo "one!two"
arch/darwin.i386-64/bin/ksh: !two": event not found
$ echo "one\!two"
one\!two
The command line is not added to the history so you can't arrow-up to
add the backslash necessary to work around this breakage; you have to
start from scratch. Way to defeat the purpose of the whole thing.
And even adding a backslash doesn't actually help, because the
backslash may escape the '!' but is still not removed itself. You're
expected to take the '!' out of the double-quoted string and use
another quoting mechanism for it.
So this breaks basic shell grammar. Double-quoted strings should not be
assigning special meaning to the '!'.
Hmm. Interestingly, zsh seems to act in a more consistent manner. If
you escape the '!' within double quotes, it does remove the escaping
backslash. So at least double-quoted strings only change from the
expected standard and don't become irreparably broken.
$ echo $ZSH_VERSION; set -o histexpand
5.8.0.2-dev
$ echo "one!two"
zsh: event not found: two
$ echo "one\!two"
one!two
Maybe I should change ksh 93u+m to act like zsh in this.
--
|| modernish -- harness the shell
||
https://github.com/modernish/modernish
||
|| KornShell lives!
||
https://github.com/ksh93/ksh