From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: shell-command - missing shell-quote-argument for program? Date: Sun, 15 Oct 2006 11:30:28 +0200 Message-ID: <4531FFB4.6070300@student.lu.se> References: <452517DC.5010007@student.lu.se> <45251C56.8010603@student.lu.se> <4531032D.6060708@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050807030104030803000408" X-Trace: sea.gmane.org 1160904678 14500 80.91.229.2 (15 Oct 2006 09:31:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 15 Oct 2006 09:31:18 +0000 (UTC) Cc: Andreas Schwab , emacs-devel@gnu.org, dominik@science.uva.nl Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 15 11:31:13 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 1GZ2Kv-0004Qv-E7 for ged-emacs-devel@m.gmane.org; Sun, 15 Oct 2006 11:31:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GZ2Ku-0000wQ-N9 for ged-emacs-devel@m.gmane.org; Sun, 15 Oct 2006 05:31:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GZ2KL-0000kF-WA for emacs-devel@gnu.org; Sun, 15 Oct 2006 05:30:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GZ2KI-0000aS-4d for emacs-devel@gnu.org; Sun, 15 Oct 2006 05:30:35 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GZ2KG-0000Yy-KU for emacs-devel@gnu.org; Sun, 15 Oct 2006 05:30:33 -0400 Original-Received: from [80.76.149.212] (helo=ch-smtp01.sth.basefarm.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GZ2T6-00085m-QP; Sun, 15 Oct 2006 05:39:41 -0400 Original-Received: from c83-249-218-244.bredband.comhem.se ([83.249.218.244]:62681 helo=[192.168.123.121]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.63) (envelope-from ) id 1GZ2KC-0005Cu-63; Sun, 15 Oct 2006 11:30:29 +0200 User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) Original-To: Eli Zaretskii In-Reply-To: X-Scan-Result: No virus found in message 1GZ2KC-0005Cu-63. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1GZ2KC-0005Cu-63 1e1a54fd63ac1d722b20c03211fc3cab 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:60754 Archived-At: This is a multi-part message in MIME format. --------------050807030104030803000408 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Eli Zaretskii wrote: >> From: Andreas Schwab >> Cc: Eli Zaretskii , >> Carsten Dominik , emacs-devel@gnu.org >> 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. > Attached a new patch. --------------050807030104030803000408 Content-Type: text/plain; name="ada-xref.el" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ada-xref.el" Index: lisp/progmodes/ada-xref.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/progmodes/ada-xref.el,v retrieving revision 1.26 diff -c -r1.26 ada-xref.el *** lisp/progmodes/ada-xref.el 10 Feb 2006 09:00:31 -0000 1.26 --- lisp/progmodes/ada-xref.el 15 Oct 2006 09:22:19 -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,1927 ---- (set-buffer (get-buffer-create "*grep*")) (while dirs (insert (shell-command-to-string ! (concat ! "grep -E -i -h " ! (shell-quote-argument (concat "^X|" regexp "( |$)")) ! " " ! (shell-quote-argument (file-name-as-directory (car dirs))) ! "*.ali"))) (set 'dirs (cdr dirs))) ;; Now parse the output --------------050807030104030803000408 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------050807030104030803000408--