From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Laimonas =?UTF-8?Q?V=C4=97bra?= Newsgroups: gmane.emacs.bugs Subject: bug#6784: 24.0.50; cmdproxy incosistency with command pathnames Date: Tue, 03 Aug 2010 23:15:30 +0300 Message-ID: <4C5878E2.1020402@gmail.com> References: <87iq3radvf.fsf@telefonica.net> <83pqxzy5me.fsf@gnu.org> <87ocdj8tyh.fsf@telefonica.net> <4C585DAB.5030609@gmail.com> <83mxt3xzqh.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1280867939 19038 80.91.229.12 (3 Aug 2010 20:38:59 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 3 Aug 2010 20:38:59 +0000 (UTC) To: Eli Zaretskii , 6784@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 03 22:38:57 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OgOGG-0001kO-UU for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Aug 2010 22:38:57 +0200 Original-Received: from localhost ([127.0.0.1]:36705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OgOGG-00057V-7T for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Aug 2010 16:38:56 -0400 Original-Received: from [140.186.70.92] (port=47215 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OgOG2-000517-Av for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2010 16:38:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OgOFv-0002mc-GN for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2010 16:38:42 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45045) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OgOFv-0002mY-Ep for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2010 16:38:35 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OgNu6-0004dc-GG; Tue, 03 Aug 2010 16:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Laimonas =?UTF-8?Q?V=C4=97bra?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Aug 2010 20:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6784 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6784-submit@debbugs.gnu.org id=B6784.128086651117819 (code B ref 6784); Tue, 03 Aug 2010 20:16:02 +0000 Original-Received: (at 6784) by debbugs.gnu.org; 3 Aug 2010 20:15:11 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OgNtH-0004dM-1F for submit@debbugs.gnu.org; Tue, 03 Aug 2010 16:15:11 -0400 Original-Received: from mail-ey0-f172.google.com ([209.85.215.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OgNtF-0004dG-8H for 6784@debbugs.gnu.org; Tue, 03 Aug 2010 16:15:10 -0400 Original-Received: by eyb7 with SMTP id 7so1668989eyb.3 for <6784@debbugs.gnu.org>; Tue, 03 Aug 2010 13:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=iaisXN6tWakBCicm+1e/Ujx5uPsUaR/4Lz2wTVXYBIs=; b=vmA4XsVNEQlzg6kuhzaOyKL5rXAAnnFFUINw1StyM4DMXhlHndHFjFVh8eiUYDaHDT W1e1bgIs9D1oIyMSYbFmxOyKLNgvPKZLuhGWFC7b2C201S9BavGOkiq5IRWl/elIZ2PW z9PDX3hsNBguyGVtr7Zgg094tKBI/PvkpyGT0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=C0ehBR6eZHdbI3pdlNM/kz8Kn2AiTOLP7QzM88B5QNWIU/Fdt7YrhMvGD6cDfSbMBW 1+sX9CBkhlu7ZldIuXrJQ8KdzHgAxZOPpSPS8OdBlhjhe21Trg3q5dNJbcn0Lf+ySw8n djzXxcXzVW+PB73ZZoNgx07g1W/ifWZ2dYBYc= Original-Received: by 10.213.25.145 with SMTP id z17mr1269843ebb.84.1280866535297; Tue, 03 Aug 2010 13:15:35 -0700 (PDT) Original-Received: from [192.168.1.72] (78-58-76-89.static.zebra.lt [78.58.76.89]) by mx.google.com with ESMTPS id u9sm5414711eeh.5.2010.08.03.13.15.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 03 Aug 2010 13:15:34 -0700 (PDT) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 SeaMonkey/2.0.6 In-Reply-To: <83mxt3xzqh.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 03 Aug 2010 16:16:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:39218 Archived-At: Eli Zaretskii wrote: >> From: Laimonas Vėbra >> Cc: 6784@debbugs.gnu.org >> >> Óscar Fuentes wrote: >> >>> That's one more incosistency: a long command works fine, then you put >>> that command as part of a pipe chain and it stops working. I guess the >>> current cmdproxy approach is the lesser evil. >> >> It's a CreateProcess() (in cmdproxy.c) _valid_ path requirement/problem; >> valid path/directory separator is (should be) '\': > > But the name of the shell, which is the only file name CreateProcess > should care about in this case, _is_ converted to use backslashes: The problem is poor CreateProcess() description and some flawless aspects. Why do we have to call CreateProcess like this: rv = CreateProcess (progname, cmdline, &sec_attrs, NULL, TRUE, 0, envblock, dir, &si, &child); where progname is 'cmd.exe' and cmdline is 'cmd.exe /c command' Somewhere i read, that this way it just works (with less problems). The problem doesn't occur, when we call CreateProcess() like this: CreateProcess ('C:\cygwin\bin\ls.exe', 'C:/cygwin/bin/ls.exe'...) That's actually the case when we are not invoking a shell (command without pipe or redirection), e.g.: M-x grep c:/cygwin/bin/ls Then progname gets correctly backslashed by: if (!get_next_token (path, &args)) canon_filename (path); progname = make_absolute (path); My guess is that in this case CreateProcess() takes correctly backslashed progname (LPCTSTR lpApplicationName), as the executable module name (program name), _ignores_ first token of cmdline (LPTSTR lpCommandLine) as it is internally treated to be the same executable module name (although with wrong slashes) and takes/passes remaining tokens of cmdline as command line args of progname. Actual bug problem arises/occurs, then we are invoking a shell (e.g. c:/cygwin/bin/ls | grep foo); then CreateProcess() gets likes this: CreateProcess('C:\WINDOWS\system32\cmd.exe', '"C:\WINDOWS\system32\cmd.exe" /c c:/cygwin/bin/ls | grep foo'...) I guess, that CreateProcess(), in this case, internally processes command line args, i.e. program names/paths ('c:/cygwin/bin/ls', 'grep'), that it passes to cmd.exe and because command name/path is not correctly/appropriately constructed (should be backslashed), it (chain CreateProcess()->cmd.exe) fails.