all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: problem using call-process with grep
Date: Sat, 24 Dec 2005 13:56:08 +0200	[thread overview]
Message-ID: <uy82azp2f.fsf@gnu.org> (raw)
In-Reply-To: <DNEMKBNJBGPAOPIJOOICOELHDAAA.drew.adams@oracle.com>

> From: "Drew Adams" <drew.adams@oracle.com>
> Date: Fri, 23 Dec 2005 17:51:04 -0800
> 
>     To figure out whether this is specific to Cygwin `grep' or a property of
>     `call-process', could someone else (e.g. on GNU/Linux) please try these:
> 
>      (call-process "/path/to/your/echo" nil t nil  "foo\\\\(bar\\\\)")
> 
>      (call-process "/path/to/your/echo" nil t nil  "foo\\(bar\\)")
> 
>     In my case, the first gives: foo\(bar\); the second gives foo(bar).

Is your `echo.exe' also a Cygwin executable?  My native Windows
executable gives foo\\(bar\\) and foo\(bar\) respectively, as it does
on GNU/Linux.

FWIW, your original test, wiz.:

    (call-process "grep" nil
		   (generate-new-buffer "Result")
		   nil "epsilon\\($\\)" "foo")

also works for me as expected, but my Grep is not a Cygwin executable,
it's a native Windows executable.

> Do the tests mean that there is a problem in the native Windows
> implementation of `call-process'? Could they mean that there is a problem in
> all Cygwin processes?

It could be, see below.

> IIUC, `call-process' doesn't spawn a shell

It doesn't (unless the command is a shell, of course).

> Could someone who works on the Windows port perhaps take a look to see if
> `call-process' is doing the right thing?

The Windows code invoked by `call-process' does quite a lot with
argument escaping and quoting, see w32proc.c:sys_spawnve.  It does so
for a good reason: Windows executables generally have the globbing
code as part of the program itself, as stock Windows shells don't
handle that.  Thus, to DTRT with special characters, such as shell
wildcard characters, quotes and escaping, the Windows code that
launches subsidiary programs needs to know whether the program being
run is a Cygwin program or a native w32 program, and it needs then to
massage the command-line arguments such that when they wind up in the
child program, they will, after removal of quotes and escape
characters done by the application's code, be in the form you wanted
them to be.

That is quite a feat, but I think the code generally does TRT (in
particular, I see that it doubles every \ for Cygwin subsidiary
programs), although having a mix of Cygwin and non-Cygwin tools will
probably put that code to a hard test.

To see what is being passed to the sub-process, the best way is to put
a breakpoint in w32proc.c:sys_spawnve, right before it is about to
call create_child, and look at the command line it generated.  I don't
have Cygwin executables installed, so I cannot look into this myself.
Don't waste your time on experiments with `echo' and other programs:
that only adds more complexity to the problem, as those other programs
also process their command line, and what you see is a result of that
processing, not what Emacs passed.

It is also possible that w32proc.c:w32_executable_type, which tries to
determine whether the subsidiary program is a Cygwin executable, fails
for some reason, so look at that function's results as well.

On top of that, it could be that Cygwin runtime has changed the way it
parses command-line arguments, and it now expects them to be quoted
differently than what Emacs does.

Finally, AFAIK Drew is using an old build of Emacs, so perhaps trying
this in a newer build is in order.

  reply	other threads:[~2005-12-24 11:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <jku0cz1e9l.fsf@glug.org>
2005-12-24  1:51 ` problem using call-process with grep Drew Adams
2005-12-24 11:56   ` Eli Zaretskii [this message]
2005-12-24 15:48     ` Drew Adams
2005-12-24 16:36       ` Eli Zaretskii
2005-12-24 16:39         ` Drew Adams
2005-12-22 18:05 Q on call-process and grep Drew Adams
2005-12-23  6:45 ` problem using call-process with grep Drew Adams
2005-12-23 18:11   ` Richard M. Stallman
2005-12-23 18:24     ` Drew Adams
2005-12-23 22:02       ` Kevin Rodgers
2005-12-23 22:18         ` Drew Adams
2005-12-23 22:42           ` David Kastrup
2005-12-23 23:16             ` Drew Adams
2005-12-23 23:20               ` David Kastrup
2005-12-23 23:44                 ` Drew Adams
2005-12-23 23:52                   ` David Kastrup
2005-12-24  0:42                     ` Drew Adams
2005-12-24  4:48                       ` Giorgos Keramidas
2005-12-24 16:32       ` Richard M. Stallman
2005-12-24 16:35         ` Drew Adams
2005-12-24 16:57           ` Eli Zaretskii
2005-12-24 17:08             ` Drew Adams
2005-12-24 17:35               ` Eli Zaretskii

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=uy82azp2f.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@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.