From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: ascott@sedona.intel.com (Andrew M. Scott) Newsgroups: gmane.emacs.help Subject: Need help improving an elisp 'GNU grep --version' query Date: Mon, 25 Aug 2003 09:42:27 -0700 Organization: Intel Corporation Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1061831102 7515 80.91.224.253 (25 Aug 2003 17:05:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 25 Aug 2003 17:05:02 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 25 19:05:00 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19rKm4-000795-00 for ; Mon, 25 Aug 2003 19:05:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19rKjw-0000GE-8D for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Aug 2003 13:02:48 -0400 Original-Newsgroups: gnu.emacs.help Original-Lines: 54 Original-NNTP-Posting-Host: chlx022.ch.intel.com Original-X-Trace: news01.intel.com 1061829749 11875 143.182.225.42 (25 Aug 2003 16:42:29 GMT) Original-X-Complaints-To: usenet@news01.intel.com Original-NNTP-Posting-Date: Mon, 25 Aug 2003 16:42:29 +0000 (UTC) User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEW9iF0bBwP0uoqJazrO rof11KlfOxn+68WjfMNuAAACc0lEQVR4nEWUzarbMBCFp5ZJ16LgdRDyXkGu1kKRm+1FWHgbI9AD lBv8+j0jx6ngXifz+cyfZkL1OLYd8uSjsNYISzAWa/Hn6jYU0wNZQ5HeAFbZTjVQ9THGU/G2S1mM Z3sk61jwscvBUoxzBuDj2Ak/KyQQ5JwZCAgGfM9LJLcNE9sZGIv3nnHd9z0vwkGyzPNKlgiOSsf2 /ZW92AaD2CsRiU0WGvd2svKukQzQPq0HeCUtbrJODLyTQx/egCUXeJ4zRQ9PcfwASJDjvAPghXCC V86KUO3vnZa7lGbO+QQJ4QcG+Y8cTDgBXKmrk//BJwaiM3jA1Q85UBgPySupVskb/KLOC8u1J74k stvwaK4KUdQxQJN0H7WwTZHvAEFTP+Y1K6WjuopD8SWfvcJ1jgoZ8QcF8JPB8AywoDIGKYYRTeJ0 l2paTg3wM1/fwJpWBYBi8MrXS+UY2dOYjxI0A7xxKSuDhdr3pJIKh/QyAYw5kVobyCnyRSJGh7EI AO1FHbNqF5YA7pWi0tS6IWzvy9T64qaLxNgB5PUvqrJ8yfOefe1vkgfYo02LO4d6RIx+k8QHce64 z8KTNwS4wpMMGdHl/CVMjzRcMWPyPOIYUbLo7BK5ynSFOp/A2j7zcBDyow51CXkCcwCsGZqQdMuD CoPAHcfRHf5591HYbmQAWcDjvh2AV+3JhpH7rsLhSRLvpiu9OlwF3YsqeVUbqNhvdpU09tuVGm8N VFdIMEEMLVw1dr4fYCvRO4MKeQqr8fZxgmeMwhnMShS19No+sBq8DHL6iu2nhVwtndJ2jgCc2vQd 0A6gMsXAwL9B/82Z8tqnqN7gH0y3CanOY+xAAAAAAElFTkSuQmCC Cancel-Lock: sha1:Lo3JQQNUUwqTMQzAQ81y/weXEuo= Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!in.100proofnews.com!in.100proofnews.com!newsfeed1.cidera.com!Cidera!news101.his.com!attws1!ip.att.net!news01.intel.com!not-for-mail Original-Xref: shelby.stanford.edu gnu.emacs.help:116127 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12045 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12045 Goal: Elisp code that can query GNU 'grep --version' feedback so I can conditionally use more advanced GNU grep-command option flags, if a more advanced version of grep is available. I'm looking for a *clean* solution that I can extend for use with the --version results of other GNU utilities. Current Ugly Code fragments: (defun my-grep-version () (interactive) (insert (shell-command "ggrep --version | head -1 | awk '{print $4}'" t nil)) (backward-delete-char 1)) This M-x my-grep-version returns "2.5.1" or "2.4.2" at point in the current buffer and "Invalid character: 01414, 780, 0x30c" in the minibuffer. ;; This next snippet would work if my-grep-version were a string variable with ;; value"2.5.1" or "2.4.2" (if (string-lessp "2.7" (my-grep-version)) (progn ;; GNU grep 2.5+ ;; (setq grep-command "ggrep -nH -i --color=always --exclude='\.newsrc.*' ") (setq grep-command "ggrep -nH -i --exclude='\.newsrc.*' ") ) ;; GNU grep 2.4 or earlier (setq grep-command "ggrep -nH -i ") ) Notes & Questions: 1. How do I capture the output of the (shell-command ....) stuff into a variable? I'd rather my-grep-version be a variable vs. a function, so I test it later in my .emacs. 2. GNU 'grep --version' returns its version information to stderr not stdout. I played with several variations of shell-command and call-process and couldn't figure out how to get the results of the (shell-command .. ) or equivalent stderr result into a variable which I could test. Thanks in advance. Andy Scott -- The opinions expressed herein are mine, *not* Intel's. Andrew M. Scott, Intel Corporation - WCCG-DA Strategic Capabilities Intel Corporation, M/S CH6-210 Voice: 480-554-9615 RIM PIN: 16545823 ascott@sedona.intel.com (e-mail with "PAGE" in subj to forward to RIM)