all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Need help improving an elisp 'GNU grep --version' query
@ 2003-08-25 16:42 Andrew M. Scott
  2003-08-25 17:01 ` Thien-Thi Nguyen
  2003-08-25 18:12 ` Kevin Rodgers
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew M. Scott @ 2003-08-25 16:42 UTC (permalink / raw)


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)

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

end of thread, other threads:[~2003-08-25 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-25 16:42 Need help improving an elisp 'GNU grep --version' query Andrew M. Scott
2003-08-25 17:01 ` Thien-Thi Nguyen
2003-08-25 18:12 ` Kevin Rodgers

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.