all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Q on call-process and grep
@ 2005-12-22 18:05 Drew Adams
  2005-12-23  6:45 ` problem using call-process with grep Drew Adams
  0 siblings, 1 reply; 22+ messages in thread
From: Drew Adams @ 2005-12-22 18:05 UTC (permalink / raw)


I'm using native Emacs on Windows, and I use Cygwin for commands like
`grep'. The (large) file "myfile" has only comma-delimited lines of words
and phrases, like this:

  word1,word2,word phrase3,word4,word phrase4,word5

Some of the lines are quite long. Lines are of varying length (different
words and phrases). There are no TABs. There are no spaces either, except
between words in phrases (none before or after commas or at eol).

If I do this from the command line or using Emacs command `grep', it works
fine:

  grep -i ",someword\\($\\|,\\)" "myfile"

If, however, I do this, then some words are found and others (which are also
present in myfile) are not found:

  (call-process "grep" nil buf nil "-i" ",someword\\($\\|,\\)" "myfile")

The same words are systematically found or not found. I haven't been able to
figure out why this doesn't work for some words (only). I visited the file
with `find-file-literally' and removed all ^M's at eol. I checked that the
commas are normal commas, thinking that some might have a different encoding
or something, making the regexp miss. All characters are ASCII, I believe
(how to check that?). The problem also doesn't seem to be related to line
lengths or the positions of the target words in the lines.

When I do `C-h C RET' it says that the buffer (for the grepped file) has no
conversion (binary), that the defaults for subprocess I/O are
`undecided-dos' for decoding and `undecided-unix' for encoding, and that
process I/O with target-pattern "bash" uses coding systems `(raw-text-dos .
raw-text-unix)'. I don't know if some of that might be a problem (or how to
change it, if it is).

I've tried having the error output sent to a file (e.g. "errors") - but to
no avail:

  (call-process "grep" nil (list (get-buffer "*scratch*") "errors")
     nil "-i" ",someword\\($\\|,\\)" "myfile")

Grep apparently does not error (the return code is 1), and the output buffer
is always empty for some words, as is also the error file.

I get the same behavior in different versions of Emacs, so I'm no doubt
missing something (i.e. there is no bug, except in my understanding). Any
ideas? Any suggestions on how to debug this? Thx.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2005-12-24 17:35 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
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

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.