News for hackers. Stuff that matters.
Re:Escaping strings in Bash using !:q by emmelaich on Friday October 02, 2020 @02:46AM (#24659685)
Note that you can precede the !:q with `echo` to see the result as well as the invocation without an error.

  $ echo !:q
  echo '# This string '\''has single'\'' "and double" quotes 
  and a $'
  # This string 'has single' "and double" quotes and a $
Re:Escaping strings in Bash using !:q by eMSF on Friday October 02, 2020 @07:06AM (#24661333)
Seeing the result of a modified history expansion is (or was) kind of a desired feature, so it's built-in just like the ability to escape stuff with :q

    $ # here be quote ' " chars

  (use :p to print but not execute)
    $ :!q:p
    '# here be quote '\'' " chars'

  (use :s to modify – no :q here because we modify the already quoted text !!, unquoted is now !-2)
    $ !:s/be/are/:p
    '# here are quote '\'' " chars'
Re:Escaping strings in Bash using !:q by slobiwan on Friday October 02, 2020 @03:01PM (#24665907)
This is very useful for saving off a one-liner .sh file once you've finally gotten the one that you want to work. I will have to remember this!

echo !:q > doagain.sh