GNU-devel ELPA - shell-quasiquote


Turn s-expressions into shell command strings.
shell-quasiquote-0.0.20201201.171117.tar, 2021-Oct-09, 10.0 KiB
Taylan Ulrich Bayırlı/Kammer <>
Home page
Browse repository
CGit or Gitweb

To install this package, run in Emacs:

M-x package-install RET shell-quasiquote RET

Full description

"Shell quasiquote" -- turn s-expressions into POSIX shell command strings.

Shells other than POSIX sh are not supported.

Quoting is automatic and safe against injection.

  (let ((file1 "file one")
        (file2 "file two"))
    (shqq (cp -r ,file1 ,file2 "My Files")))
      => "cp -r 'file one' 'file two' 'My Files'"

You can splice many arguments into place with ,@foo.

  (let ((files (list "file one" "file two")))
    (shqq (cp -r ,@files "My Files")))
      => "cp -r 'file one' 'file two' 'My Files'"

Note that the quoting disables a variety of shell expansions like ~/foo,
$ENV_VAR, and e.g. {x..y} in GNU Bash.

You can use ,,foo to escape the quoting.

  (let ((files "file1 file2"))
    (shqq (cp -r ,,files "My Files")))
      => "cp -r file1 file2 'My Files'"

And ,,@foo to splice and escape quoting.

  (let* ((arglist '("-x 'foo bar' -y baz"))
         (arglist (append arglist '("-z 'qux fux'"))))
    (shqq (command ,,@arglist)))
      => "command -x 'foo bar' -y baz -z 'qux fux'"

Neat, eh?

Old versions

shell-quasiquote-0.0.20201201.221117.tar.lz2020-Dec-141.96 KiB