From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: problem using call-process with grep Date: Thu, 22 Dec 2005 22:45:30 -0800 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1135320425 8356 80.91.229.2 (23 Dec 2005 06:47:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 23 Dec 2005 06:47:05 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 23 07:47:02 2005 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Epghh-0005Zv-Nr for ged-emacs-devel@m.gmane.org; Fri, 23 Dec 2005 07:47:02 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Epgij-00019A-O7 for ged-emacs-devel@m.gmane.org; Fri, 23 Dec 2005 01:48:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EpghR-00014t-HT for emacs-devel@gnu.org; Fri, 23 Dec 2005 01:46:45 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EpghO-00013w-Tb for emacs-devel@gnu.org; Fri, 23 Dec 2005 01:46:44 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EpghN-00013m-T6 for emacs-devel@gnu.org; Fri, 23 Dec 2005 01:46:42 -0500 Original-Received: from [148.87.122.30] (helo=rgminet01.oracle.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1Epggd-0005NK-AM for emacs-devel@gnu.org; Fri, 23 Dec 2005 01:45:55 -0500 Original-Received: from rgmsgw300.us.oracle.com (rgmsgw300.us.oracle.com [138.1.186.49]) by rgminet01.oracle.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id jBN6jXbm007442 for ; Thu, 22 Dec 2005 23:45:33 -0700 Original-Received: from rgmsgw300.us.oracle.com (localhost [127.0.0.1]) by rgmsgw300.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id jBN6jX0V006013 for ; Thu, 22 Dec 2005 23:45:33 -0700 Original-Received: from dradamslap (dhcp-amer-rmdc-csvpn-gw6-141-144-112-81.vpn.oracle.com [141.144.112.81]) by rgmsgw300.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with SMTP id jBN6jW0A006002 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 22 Dec 2005 23:45:33 -0700 Original-To: "Emacs-Devel" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:48239 Archived-At: I hesitate whether to send this to emacs-devel or help-gnu-emacs. I doubt that this is a bug - it's probably user ignorance, because I see the same behavior in both Emacs 20 and 22. Perhaps someone can tell me what the problem is. Type this in a file foo, ending the file with a newline: alpha,beta,gamma,delta,epsilon Evaluate this: (call-process "grep" nil (generate-new-buffer "Result") nil "epsilon$" "foo") As expected, buffer Result contains the same text as file foo. The evaluation returns 0. Change the regexp passed to `grep' to this: "epsilon\\($\\)" and try again. I expect the same result, but, instead, buffer Result is empty and the evaluation returns 1. If I run the Emacs `grep' command like this (with or without the options), it works: grep -nH -e "epsilon\\($\\)" foo This gives the same result using Emacs `grep' (single backslashes): grep "epsilon\($\)" foo (Since these are not Lisp strings, but input args to the Emacs `grep' command, which it passes on to the `grep' process, I'm a bit surprised to see that the double-backslash version works, but it does.) I'm using Cygwin `grep' (GNU `grep'), for which the doc says that \(, $, and \) are supported in the usual way. And if I run grep from the Cygwin command line (with either parenthetical regexp - single or double backslashes), it works OK. I only have the problem when I use `call-process'. I'm sure I'm missing something simple (doing something wrong in the call to `call-process') - I'd be grateful for the explanation. FWIW: The coding system for the file foo is undecided-unix. The defaults for subprocess I/O are undecided-dos (decoding) and undecided-unix (encoding). I've loaded cywin-mount.el, version 1.2.1 - 2001-05-13. shell-file-name is "bash". w32-quote-process-arg is ?\". process-coding-system-alist is (("bash" raw-text-dos . raw-text-unix)). In GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2005-06-26 on NONIQPC X server distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.3) --cflags -I../../jpeg-6b-3/include -I../../libpng-1.2.8/include -I../. ./tiff-3.6.1-2/include -I../../xpm-nox-4.2.0/include -I../../zlib-1.2.2/incl ude' Thanks.