From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: taylanbayirli@gmail.com (Taylan Ulrich =?UTF-8?Q?Bay=C4=B1rl=C4=B1/Kammer?=) Newsgroups: gmane.emacs.bugs Subject: bug#21702: shell-quote-argument semantics and safety Date: Sun, 18 Oct 2015 17:26:19 +0200 Message-ID: <87y4f0qjtw.fsf_-_@T420.taylan> References: <871tcstkuk.fsf@T420.taylan> 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 1445182037 11751 80.91.229.3 (18 Oct 2015 15:27:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Oct 2015 15:27:17 +0000 (UTC) To: 21702@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 18 17:27:10 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ZnprZ-0002Dw-Kp for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Oct 2015 17:27:09 +0200 Original-Received: from localhost ([::1]:34286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnprY-000260-N7 for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Oct 2015 11:27:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnprV-00025v-VA for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2015 11:27:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnprS-0000s6-P4 for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2015 11:27:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnprS-0000ru-LF for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2015 11:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZnprS-00071w-9o for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2015 11:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: taylanbayirli@gmail.com (Taylan Ulrich =?UTF-8?Q?Bay=C4=B1rl=C4=B1/Kammer?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Oct 2015 15:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21702 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21702-submit@debbugs.gnu.org id=B21702.144518198426981 (code B ref 21702); Sun, 18 Oct 2015 15:27:02 +0000 Original-Received: (at 21702) by debbugs.gnu.org; 18 Oct 2015 15:26:24 +0000 Original-Received: from localhost ([127.0.0.1]:55277 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Znpqp-000717-Uc for submit@debbugs.gnu.org; Sun, 18 Oct 2015 11:26:24 -0400 Original-Received: from mail-wi0-f179.google.com ([209.85.212.179]:33212) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Znpqn-00070z-UZ for 21702@debbugs.gnu.org; Sun, 18 Oct 2015 11:26:22 -0400 Original-Received: by wijp11 with SMTP id p11so67836959wij.0 for <21702@debbugs.gnu.org>; Sun, 18 Oct 2015 08:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-type:content-transfer-encoding; bh=xW33n5NEBhVQIFapgO+ysA2SNBfsLoMxFLCwMduK01A=; b=OyXH/sNwhLU8YVCYJvPugr6kMuKdafuCddDVZWEJMMV9vqkS8mpoU+V11rbSonR2tE Z0HdqNjn1Lc8MtxRG3+0PDczGhsRgdfhXnz6jCURB17PHbqDygGGGGFbuUnaqYj+hJvN +oEq4r5KZLxTkujMkz6HZkvmV815RdqBiCWx47iLizbNCY22xeACxdAoncjTBtop9FPN f+J32tYBp2mxGvK3nsr7JL7LaR6+/T63YSLmVbYR82w1xEFR/YPueGXymB8RIg5oFJJR i/vNozQWTGrdP/2S1bB05/IpiCwpyXonj1Jdbcgx8Fm2J+lknSfjbBTkRhxDGWb/1aQx Idww== X-Received: by 10.194.192.6 with SMTP id hc6mr27284056wjc.33.1445181981379; Sun, 18 Oct 2015 08:26:21 -0700 (PDT) Original-Received: from T420.taylan ([2a02:908:c32:4740:221:ccff:fe66:68f0]) by smtp.gmail.com with ESMTPSA id p4sm11293528wia.15.2015.10.18.08.26.19 for <21702@debbugs.gnu.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 08:26:20 -0700 (PDT) In-Reply-To: (GNU bug Tracking System's message of "Sun, 18 Oct 2015 12:37:02 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107711 Archived-At: On the development list it has been pointed out that the Info manual contains more verbose documentation on this function, although it doesn't clarify the semantics much either. =3D=3D=3D snip =3D=3D=3D Lisp programs sometimes need to run a shell and give it a command that contains file names that were specified by the user. These programs ought to be able to support any valid file name. But the shell gives special treatment to certain characters, and if these characters occur in the file name, they will confuse the shell. To handle these characters, use the function =E2=80=98shell-quote-argument=E2=80=99: -- Function: shell-quote-argument argument This function returns a string that represents, in shell syntax, an argument whose actual contents are ARGUMENT. It should work reliably to concatenate the return value into a shell command and then pass it to a shell for execution. Precisely what this function does depends on your operating system. The function is designed to work with the syntax of your system=E2=80= =99s standard shell; if you use an unusual shell, you will need to redefine this function. ;; This example shows the behavior on GNU and Unix systems. (shell-quote-argument "foo > bar") =E2=87=92 "foo\\ \\>\\ bar" ;; This example shows the behavior on MS-DOS and MS-Windows. (shell-quote-argument "foo > bar") =E2=87=92 "\"foo > bar\"" Here=E2=80=99s an example of using =E2=80=98shell-quote-argument=E2=80= =99 to construct a shell command: (concat "diff -c " (shell-quote-argument oldfile) " " (shell-quote-argument newfile)) =3D=3D=3D /snip =3D=3D=3D I'm not sure if that needs change, given the change to the docstring, which counts as the more authoritative documentation of the precise semantics if I'm not mistaken. Taylan