From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Random832 Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add shell-quasiquote. Date: Sat, 17 Oct 2015 15:14:26 -0400 Message-ID: <87a8rh2tpp.fsf@fastmail.com> References: <87si59wj42.fsf@T420.taylan> <83eggt4esi.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1445110238 20530 80.91.229.3 (17 Oct 2015 19:30:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Oct 2015 19:30:38 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 17 21:30:29 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZnXBU-0001ej-7u for ged-emacs-devel@m.gmane.org; Sat, 17 Oct 2015 21:30:28 +0200 Original-Received: from localhost ([::1]:59559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnXBT-0006qb-7v for ged-emacs-devel@m.gmane.org; Sat, 17 Oct 2015 15:30:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnXBD-0006qG-Sv for emacs-devel@gnu.org; Sat, 17 Oct 2015 15:30:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnXBA-0002K1-Mb for emacs-devel@gnu.org; Sat, 17 Oct 2015 15:30:11 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:40604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnXBA-0002Iz-FZ for emacs-devel@gnu.org; Sat, 17 Oct 2015 15:30:08 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZnXB6-0001Ii-9v for emacs-devel@gnu.org; Sat, 17 Oct 2015 21:30:04 +0200 Original-Received: from c-68-39-146-59.hsd1.in.comcast.net ([68.39.146.59]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 17 Oct 2015 21:30:04 +0200 Original-Received: from random832 by c-68-39-146-59.hsd1.in.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 17 Oct 2015 21:30:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 27 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-68-39-146-59.hsd1.in.comcast.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:0OP2JOfRv/UMWJaYq1zL4LXBJkA= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:191875 Archived-At: Eli Zaretskii writes: >> From: taylanbayirli@gmail.com (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. For reference: (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? Certainly not csh, the mechanism it uses for newlines doesn't work there.