4

Is it possible to disable history expansion inside double quotes?

I do not want history expansion to be completely disabled, as I still use it, but I see no reason to expand the history inside a string ...

An example of my desired behavior:

$ echo "Hello!"
Hello!
$ !!
Hello!
6
  • echo "Hello\!". Backslash ("\ ") flips the "I am special" bit on \ .
    – waltinator
    Commented Apr 10, 2021 at 16:39
  • 1
    @waltinator I know, but I do not want to escape it. I also dislike how the behavior is different between scripts and my interactive shell.
    – HappyFace
    Commented Apr 10, 2021 at 17:03
  • echo 'Hello!'.
    – waltinator
    Commented Apr 10, 2021 at 17:04
  • @waltinator You're so clever.
    – HappyFace
    Commented Apr 10, 2021 at 17:08
  • how about in echo "$(echo !!; echo ";;")"? Do you consider that !! to be inside double quotes? Commented Jan 8 at 8:25

0

You must log in to answer this question.

Browse other questions tagged .