From: "Laimonas Vėbra" <laimonas.vebra@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, 6784@debbugs.gnu.org
Subject: bug#6784: 24.0.50; cmdproxy incosistency with command pathnames
Date: Tue, 03 Aug 2010 23:15:30 +0300 [thread overview]
Message-ID: <4C5878E2.1020402@gmail.com> (raw)
In-Reply-To: <83mxt3xzqh.fsf@gnu.org>
Eli Zaretskii wrote:
>> From: Laimonas Vėbra<laimonas.vebra@gmail.com>
>> 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.
next prev parent reply other threads:[~2010-08-03 20:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-03 15:56 bug#6784: 24.0.50; cmdproxy incosistency with command pathnames Óscar Fuentes
2010-08-03 17:21 ` Eli Zaretskii
2010-08-03 17:52 ` Óscar Fuentes
2010-08-03 18:15 ` Eli Zaretskii
2010-08-03 18:19 ` Laimonas Vėbra
2010-08-03 19:28 ` Eli Zaretskii
2010-08-03 20:15 ` Laimonas Vėbra [this message]
2010-08-03 20:57 ` Laimonas Vėbra
2010-08-04 3:08 ` Eli Zaretskii
2010-08-04 10:28 ` Laimonas Vėbra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C5878E2.1020402@gmail.com \
--to=laimonas.vebra@gmail.com \
--cc=6784@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.