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: RE: grep command doc - point out that you can chain now Date: Mon, 17 Jul 2006 22:53:55 -0700 Message-ID: References: <17596.27496.792600.13733@kahikatea.snap.net.nz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1153202086 30012 80.91.229.2 (18 Jul 2006 05:54:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 18 Jul 2006 05:54:46 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 18 07:54:45 2006 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 1G2iXQ-0006Uq-KJ for ged-emacs-devel@m.gmane.org; Tue, 18 Jul 2006 07:54:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G2iXQ-0000Pl-95 for ged-emacs-devel@m.gmane.org; Tue, 18 Jul 2006 01:54:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G2iXC-0000P8-9u for emacs-devel@gnu.org; Tue, 18 Jul 2006 01:54:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G2iXA-0000NQ-VB for emacs-devel@gnu.org; Tue, 18 Jul 2006 01:54:17 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G2iXA-0000NH-G7 for emacs-devel@gnu.org; Tue, 18 Jul 2006 01:54:16 -0400 Original-Received: from [141.146.126.228] (helo=agminet01.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.52) id 1G2iZz-0001pP-Gn for emacs-devel@gnu.org; Tue, 18 Jul 2006 01:57:11 -0400 Original-Received: from rcsmt250.oracle.com (rcsmt250.oracle.com [148.87.90.195]) by agminet01.oracle.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id k6G8RQXg013256 for ; Tue, 18 Jul 2006 00:54:14 -0500 Original-Received: from dhcp-amer-whq-csvpn-gw3-141-144-80-94.vpn.oracle.com by rcsmt251.oracle.com with ESMTP id 1579724431153202036; Mon, 17 Jul 2006 23:53:56 -0600 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) Importance: Normal In-Reply-To: <17596.27496.792600.13733@kahikatea.snap.net.nz> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 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:57246 Archived-At: > Probably because you knew it didn't work in the past. > > Yes, I said that myself. You predicted Richard's reponse? Oops - I thought you were quoting me; my bad. I thought I said that one reason I didn't expect it was that I knew it didn't work in the past. > And, I added, also because what you type is apparently not > the arguments to the Unix/GNU-Linux `grep' command, but something > possibly much richer. Even if someone were not used to Emacs 20 > `grep' behavior, if s?he were used to the Unix/GNU-Linux `grep' > command, then s?he would expect to be inputting > just the `grep' args, no? Grep uses start-process just like shell-command. You saw it as natural to use the latter with a pipe so I'm surprised that you feel it needs explaining for grep. You know something? I'm learning more and more here. I was about to write that I wouldn't naturally expect just any old Unix/GNU-Linux command used in Emacs to accept more than the args defined for that command. Looking for "proof", I tried `M-x man RET grep | grep grep'. My intention was to show that `man', another Unix command, would barf and not accept the piping. Well... I was wrong. That works too! And that one works in Emacs 20 too. I don't know; is this obvious to others? It really wasn't to me. Fun. And I wonder now if this shouldn't be documented generally, because it's apparently not an Emacs `grep' thing, but it is, as you say, because `start-process' is used. I'd say that this should perhaps be made more clear in the Emacs-Lisp doc for `start-process'. That doc does point out that `start-process' starts an asynchronous process, and it says that whatever you give it as &rest args are treated like command-line args, but, though I've read that before and used `start-process' several times, I never interpreted "command-line arguments for the program" (e.g. grep) to mean whatever might be on the command line, including pipes (and redirection etc., presumably). How about rewording this, to emphasize the generality (a shell command line passed to the process) and de-emphasize "arguments" to the program? I guess I wasn't thinking well enough about processes interpreting the command line; I don't know if others might think similarly. And, because Emacs users will not know about it, and because `grep', in particular, is so useful when chained, I still think the grep-piping use pattern is worth pointing out in the Emacs `grep' doc. Grep failed in the past because grep-use-null-device was automatically t (or more accurately "/dev/null" was always appended to the end of the command) I see. By saying that I would expect it to work, I mean I can't see why it wouldn't. Could you see a reason? No, now that I understand it, I understand it (I think) ;-). M-x grep says: Run grep (like this): grep -nH -e not Run grep (with the following arguments): -nH -e Yes, I noticed that prompt change, but the subtlety didn't sink in. It's not just running `grep' with those options, however. It's starting an asynchronous process and passing `grep -nH -e...' to it. That's not really the same thing as executing `grep -hH -e ', it seems to me. Behaviour depends on the version of grep and the value of grep-command but ultimately the value of grep-use-null-device. It has to do with the fact that without "-H" grep doesn't output the filename if only one is given in the input (hence the dummy extra: /dev/null). I don't which versions of grep have "-H" or when it was added to GNU/Linux. I see. Good to know. I'm not sure how much of this info is worth documenting, but I'm convinced some of it is: 1. Explain better that `start-process' accepts a shell command line, not just arguments for the command. 2. Explain that (depending on your version of grep), you might be able to chain grep commands. Very enlightening - thx.