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: Mon, 19 Oct 2015 08:56:05 +0300 Message-ID: <836123ieq2.fsf@gnu.org> References: <87si59wj42.fsf@T420.taylan> <83eggt4esi.fsf@gnu.org> <87fv19wh7b.fsf@T420.taylan> <83bnbx4d7e.fsf@gnu.org> <87twppuzfu.fsf@T420.taylan> <83a8rh48if.fsf@gnu.org> <87io65utmt.fsf@T420.taylan> <5622B337.4050700@yandex.ru> <876125uqzw.fsf@T420.taylan> <5622BE84.8030209@yandex.ru> <87twpptato.fsf@T420.taylan> <87pp0cehly.fsf@gmx.de> <878u70trqz.fsf@T420.taylan> <87si58phte.fsf@gmx.de> <87io648h8r.fsf@fastmail.com> <83oafwhykw.fsf@gnu.org> <8737x87zq6.fsf@fastmail.com> <83fv18hs32.fsf@gnu.org> <22052.29299.917171.338544@turnbull.sk.tsukuba.ac.jp> <837fmjigm6.fsf@gnu.org> <56247D77.1010305@dancol.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1445234183 9491 80.91.229.3 (19 Oct 2015 05:56:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 Oct 2015 05:56:23 +0000 (UTC) Cc: random832@fastmail.com, stephen@xemacs.org, emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 19 07:56:14 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 1Zo3Qb-00071j-Ua for ged-emacs-devel@m.gmane.org; Mon, 19 Oct 2015 07:56:14 +0200 Original-Received: from localhost ([::1]:36610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo3Qb-0000yl-3k for ged-emacs-devel@m.gmane.org; Mon, 19 Oct 2015 01:56:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo3QX-0000yd-2m for emacs-devel@gnu.org; Mon, 19 Oct 2015 01:56:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zo3QT-0005wR-Pk for emacs-devel@gnu.org; Mon, 19 Oct 2015 01:56:09 -0400 Original-Received: from mtaout27.012.net.il ([80.179.55.183]:46251) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo3QT-0005wM-DA for emacs-devel@gnu.org; Mon, 19 Oct 2015 01:56:05 -0400 Original-Received: from conversion-daemon.mtaout27.012.net.il by mtaout27.012.net.il (HyperSendmail v2007.08) id <0NWG00600DKT4W00@mtaout27.012.net.il> for emacs-devel@gnu.org; Mon, 19 Oct 2015 08:51:54 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout27.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NWG003AADMIZ620@mtaout27.012.net.il>; Mon, 19 Oct 2015 08:51:54 +0300 (IDT) In-reply-to: <56247D77.1010305@dancol.org> 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.183 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:192033 Archived-At: > Cc: random832@fastmail.com, emacs-devel@gnu.org > From: Daniel Colascione > Date: Sun, 18 Oct 2015 22:19:51 -0700 > > On 10/18/2015 10:15 PM, Eli Zaretskii wrote: > >> Date: Mon, 19 Oct 2015 13:32:51 +0900 > >> From: "Stephen J. Turnbull" > >> Cc: Random832 , > >> emacs-devel@gnu.org > >> > >> Eli Zaretskii writes: > >> > Random832 writes: > >> > >> > > Yes, sorry. A typical Windows program (at least, one compiled with > >> > > MSVC's setargv.obj) will try to interpret wildcards in any part of > >> > > CommandLineToArgv's result which contains a ? or * character, with > >> > > no provision to prevent it from doing so. (In particular, double > >> > > quotes have no effect). > >> > > >> > This actually depends on the startup code. The latest release of > >> > mingw.org's MinGW runtime does allow you to quote wildcard characters. > >> > And on Windows XP and older even the other runtimes allow that. > >> > > >> > In any case, this is not an Emacs problem. > >> > >> Of course it is, in a security context. I don't think it matters > >> anywhere near as much as code injection, but if Emacs is built with > >> one of those runtimes that doesn't allow wildcards to be disabled, its > >> users will be affected. > >> > >> I think it probably can be immediately judged irrelevant (and perhaps > >> that's what you meant) if Emacs is normally built with a runtime that > >> doesn't interpret quoted wildcards, and the runtimes that always > >> interpret wildcards are not supported. > > > > That's a misunderstanding: the runtime in question is the one used > > with the program that Emacs invokes, not the one used to run Emacs > > itself. On MS-Windows, the expansion of wildcards on the command line > > is done by the application which accepts the command line (in its > > startup code, before the main function is invoked), so that's what > > determines whether a quoted "*" will or will not be expanded. The > > invoking Emacs cannot control or affect that in any way. > > But maybe we can make the argument-quoting style a particular program > expects a user-customizable variable. Unless I misunderstand you, this isn't possible. Or maybe there's some subtle trick that I'm not aware of. Here are the details for those who don't already know them. There are only 2 styles of quoting used by native Windows programs, and a 3rd style used by ported Posix shells. Emacs already supports the 3rd style automatically (by examining the program it is about to invoke). As to the other 2 styles, they are the "cmd style" and the style of MS runtime's setargv. The "cmd style" is AFAIK supported only by cmd itself and compatible shells, which leaves us with the setargv style. The problem which started this sub-thread is that Microsoft changed the behavior of setargv, which lives in the system shared library every C program links against, starting with Windows Vista (or maybe Windows 7, I never used Vista). Before the change, quoting a wildcard "like this" would disable its globbing; after the change, quoted wildcards are globbed regardless, and there's no alternative way of protecting wildcards from globbing, AFAIK, except make your program avoid calling setargv, and instead call your own globbing function (which is what the latest MinGW runtime does). The upshot of this is that a program will behave differently depending on the Windows version it runs on, unless it was linked with the latest MinGW runtime. So given all this mess, how would you suggest to allow customization of the wildcard quoting? (Btw, in general, I'd prefer Emacs to DTRT by default, without asking the user to customize anything. If possible, of course.)