Mail Archives: djgpp-workers/2001/01/27/05:19:45
> From: Michel de Ruiter <Michel AT smr DOT nl>
> Date: Fri, 26 Jan 2001 18:21:14 +0100
>
> - start emacs -q
> - type M-! (shell-command)
> - type "grep notfound c:/autoexec.bat|wc" and RETs
>
> The file c:/autoexec.bat should exist, and the string "notfound" should not
> occur in it.
> Emacs replies to me with:
> (Shell command succeeded with no output)
> Instead of:
> 0 0 0
This has nothing to do with either Emacs or Grep. Try the same
command in a Makefile, and you will see that Make exhibits the same
behavior. Conclusion: it's our `system' that does this.
And indeed it seems like a ``feature'' in `system': the internal
COMMAND.COM emulator stops a pipe once a program in the pipe exits
with a non-zero status. And Grep exits with a non-zero status if it
doesn't find any matches. So `wc' in the example above doesn't get
run at all.
To get around this, try this in Emacs:
M-! command.com /c grep notfound c:/autoexec.bat | wc RET
The funny thing is, this has been in `system' forever, so I wonder
whether there's a good reason for it. Morten, could you see any such
reason?
I guess I could fix this by keeping the pipe running as long as the
commands return non-negative status. But this won't solve all the
problems, since a command could legitimately exit with a status of -1,
and we cannot distinguish between -1 returned by a program and -1
returned by _dos_exec and friends. I don't think it is wise to keep
the pipe running if some command cannot be found or cannot be run, is
it?
Thoughts?
- Raw text -