emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell-command - missing shell-quote-argument for program?


From: Eli Zaretskii
Subject: Re: shell-command - missing shell-quote-argument for program?
Date: Sat, 14 Oct 2006 20:15:21 +0200

> From: Andreas Schwab <address@hidden>
> Cc: Eli Zaretskii <address@hidden>,
>       Carsten Dominik <address@hidden>, address@hidden
> Date: Sat, 14 Oct 2006 19:50:01 +0200
> 
> > diff -c -r1.26 ada-xref.el
> > *** ada-xref.el    10 Feb 2006 09:00:31 -0000    1.26
> > --- ada-xref.el    11 Oct 2006 22:55:48 -0000
> > ***************
> > *** 1916,1923 ****
> >        (set-buffer (get-buffer-create "*grep*"))
> >        (while dirs
> >      (insert (shell-command-to-string
> > !          (concat "egrep -i -h '^X|" regexp "( |$)' "
> > !              (file-name-as-directory (car dirs)) "*.ali")))
> >      (set 'dirs (cdr dirs)))
> >
> >        ;;  Now parse the output
> > --- 1916,1926 ----
> >        (set-buffer (get-buffer-create "*grep*"))
> >        (while dirs
> >      (insert (shell-command-to-string
> > !          (concat "egrep -i -h '^X|"
> > !                          (shell-quote-argument regexp)
> 
> This is wrong, the argument is already enclosed in single quotes.

Actually, I think that using '..' quoting is wrong, because it assumes
a Posix shell.  I think this should be rewritten by removing the
single quotes and instead quoting (via shell-quote-argument) the
entire regexp that is the result of `(concat "^X|" regexp "( |$)")'.
Do you agree that this is more portable?

Also, I thought that the issue here was with quoting the elements of
the `dirs' list, since they are file names that could include embedded
whitespace and other characters special to the shell.

Btw, while we are at that, `egrep' might not work with the latest
versions of GNU Grep, where `egrep' is a shell script that requires
/bin/sh.  "grep -E" is better, I think.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]