emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add shell-quasiquote.


From: Eli Zaretskii
Subject: Re: [PATCH] Add shell-quasiquote.
Date: Sat, 17 Oct 2015 22:44:25 +0300

> From: Random832 <address@hidden>
> Date: Sat, 17 Oct 2015 15:14:26 -0400
> 
> Eli Zaretskii <address@hidden> writes:
> >> From: address@hidden (Taylan Ulrich Bayırlı/Kammer)
> >> +;;; Like `shell-quote-argument', but much simpler in implementation.
> >> +(defun shqq--quote-string (string)
> >> +  (concat "'" (replace-regexp-in-string "'" "'\\\\''" string) "'"))
> >
> > It might be simpler, but it's wrong, because the result is only
> > correct for Posix shells.
> >
> > Please do use shell-quote-argument instead.
> 
> It's also simpler than the POSIX section of shell-quote-argument.

Simpler doesn't mean correct.

> (defun shell-quote-argument (argument)
>   [...] (cond [...] (t
>     (if (equal argument "")
>         "''"
>       ;; Quote everything except POSIX filename characters.
>       ;; This should be safe enough even for really weird shells.
>       (replace-regexp-in-string
>        "\n" "'\n'"
>        (replace-regexp-in-string "[^-0-9a-zA-Z_./\n]" "\\\\\\&" argument))))))
> 
> I wonder what "really weird shells" this refers to?

The set of characters special to an arbitrary shell is not known in
advance.

> Certainly not csh, the mechanism it uses for newlines doesn't work
> there.

What did you try that didn't work with csh?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]