From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add shell-quasiquote. Date: Sat, 17 Oct 2015 22:44:25 +0300 Message-ID: <837fml46w6.fsf@gnu.org> References: <87si59wj42.fsf@T420.taylan> <83eggt4esi.fsf@gnu.org> <87a8rh2tpp.fsf@fastmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: ger.gmane.org 1445111083 1106 80.91.229.3 (17 Oct 2015 19:44:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Oct 2015 19:44:43 +0000 (UTC) Cc: emacs-devel@gnu.org To: Random832 Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 17 21:44:34 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 1ZnXP6-0006Oa-Ko for ged-emacs-devel@m.gmane.org; Sat, 17 Oct 2015 21:44:32 +0200 Original-Received: from localhost ([::1]:59583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnXP5-000823-Ma for ged-emacs-devel@m.gmane.org; Sat, 17 Oct 2015 15:44:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnXP2-00081y-8G for emacs-devel@gnu.org; Sat, 17 Oct 2015 15:44:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnXOx-0006F1-7x for emacs-devel@gnu.org; Sat, 17 Oct 2015 15:44:28 -0400 Original-Received: from mtaout29.012.net.il ([80.179.55.185]:32792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnXOx-0006Ev-0E for emacs-devel@gnu.org; Sat, 17 Oct 2015 15:44:23 -0400 Original-Received: from conversion-daemon.mtaout29.012.net.il by mtaout29.012.net.il (HyperSendmail v2007.08) id <0NWD00N00QKSNJ00@mtaout29.012.net.il> for emacs-devel@gnu.org; Sat, 17 Oct 2015 22:43:44 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout29.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NWD00I19QSVLC50@mtaout29.012.net.il>; Sat, 17 Oct 2015 22:43:43 +0300 (IDT) In-reply-to: <87a8rh2tpp.fsf@fastmail.com> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.185 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:191876 Archived-At: > From: Random832 > Date: Sat, 17 Oct 2015 15:14:26 -0400 >=20 > Eli Zaretskii writes: > >> From: taylanbayirli@gmail.com (Taylan Ulrich Bay=C4=B1rl=C4=B1/K= ammer) > >> +;;; Like `shell-quote-argument', but much simpler in implementa= tion. > >> +(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. >=20 > 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]" "\\\\\\&" arg= ument)))))) >=20 > 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?