From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Re: Fixing Windows and DOS command line argument quoting Date: Tue, 26 Apr 2011 18:25:44 -0700 Message-ID: <4DB77098.4000301@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1303867559 3255 80.91.229.12 (27 Apr 2011 01:25:59 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 27 Apr 2011 01:25:59 +0000 (UTC) Cc: Emacs-devel@gnu.org To: Ben Key Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 27 03:25:53 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QEtVn-0000Wj-Nw for ged-emacs-devel@m.gmane.org; Wed, 27 Apr 2011 03:25:52 +0200 Original-Received: from localhost ([::1]:43842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEtVn-0007px-6H for ged-emacs-devel@m.gmane.org; Tue, 26 Apr 2011 21:25:51 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:58239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEtVl-0007ps-El for Emacs-devel@gnu.org; Tue, 26 Apr 2011 21:25:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QEtVk-0003Md-B5 for Emacs-devel@gnu.org; Tue, 26 Apr 2011 21:25:49 -0400 Original-Received: from mail-pz0-f41.google.com ([209.85.210.41]:45909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEtVk-0003MY-6O for Emacs-devel@gnu.org; Tue, 26 Apr 2011 21:25:48 -0400 Original-Received: by pzk4 with SMTP id 4so1015281pzk.0 for ; Tue, 26 Apr 2011 18:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=OhDntg2j3KTuh7tfO39D0KPNdnR1j9pauEZf8ZbwMJ0=; b=IMV3CRUNmstvcz/uqeIC0H+LNNXh3yAiXiojP/KHPOcaA6ar5sD08F1QTgp8wPon8U a5peSixKQQqlxxCDzQH+Ld0UUU34PCtFYf/Y318+NX5VBSMhaZoIWZUwbC4fJnuCfH2s 1DPwdOHHQz+ymtQ2jwv6Vc97BcXpKMeeBsuec= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=AHtoCDdiwjjRtIxSAkP3k7JuVCwgdrNcAd/RX2Yv8Gau/9TsXoVNVWYO3caSuee+/3 4MKH0MJMVSImeIh36avrYTcDKhiEXg5cAR5S/V+m2a+q/l/XxsDisKMXYrakFzNvHwZq DEya6rkODcorhk/IA4s04ZiSdsc6wSrN/16AU= Original-Received: by 10.68.5.164 with SMTP id t4mr1605632pbt.167.1303867547280; Tue, 26 Apr 2011 18:25:47 -0700 (PDT) Original-Received: from [0.0.0.0] (c-67-183-23-114.hsd1.wa.comcast.net [67.183.23.114]) by mx.google.com with ESMTPS id k2sm209611pbj.47.2011.04.26.18.25.45 (version=SSLv3 cipher=OTHER); Tue, 26 Apr 2011 18:25:46 -0700 (PDT) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.41 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:138823 Archived-At: On 4/26/2011 5:58 PM, Ben Key wrote: > Daniel Colascione writes: > > > After another reading of cmdproxy.c, I also see that the > > CreateProcess path also doesn't expand environment %variable% > > references, and that doesn't fall back to cmd if the command > > to be executed contains them. While we could expand these > > variables, doing so would move us even closer to > > reimplementing half of cmd.exe. > > You are exaggerating a great deal. It is a single function call, > ExpandEnvironmentStrings, documented at > http://msdn.microsoft.com/en-us/library/ms724265%28v=vs.85%29.aspx. > Patching cmdproxy.c to use ExpandEnvironmentStrings before calling > CreateProcess would add at most 10 lines of code. This is by no means > "reimplementing half of cmd.exe." > I actually didn't know about ExpandEnvironmentStrings. Thank you for the link; this function may be useful in some cases. But as the comments on the linked MSDN page point out, ExpandEnvironmentStrings doesn't expand variable references quite same way cmd does, and it would produce incorrect results for us whether we ran it before or after level-2-dequoting. Since cmdproxy should mimic cmd's processing when bypassing cmd itself, ExpandEnvironmentStrings would be inappropriate for our purposes. The issue is moot, however, because cmdproxy now punts processing variable references to cmd itself, and I suspect that Eli Zaretskii is correct when he says that such variable references are rare.