From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: shell-command - missing shell-quote-argument for program? Date: Sat, 14 Oct 2006 20:15:21 +0200 Message-ID: References: <452517DC.5010007@student.lu.se> <45251C56.8010603@student.lu.se> <4531032D.6060708@student.lu.se> Reply-To: Eli Zaretskii NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1160849754 10469 80.91.229.2 (14 Oct 2006 18:15:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 14 Oct 2006 18:15:54 +0000 (UTC) Cc: lennart.borgman.073@student.lu.se, emacs-devel@gnu.org, dominik@science.uva.nl Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 14 20:15:52 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 1GYo33-0000Ua-7L for ged-emacs-devel@m.gmane.org; Sat, 14 Oct 2006 20:15:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GYo30-0000si-H4 for ged-emacs-devel@m.gmane.org; Sat, 14 Oct 2006 14:15:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GYo2q-0000sK-06 for emacs-devel@gnu.org; Sat, 14 Oct 2006 14:15:36 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GYo2l-0000pz-Ih for emacs-devel@gnu.org; Sat, 14 Oct 2006 14:15:35 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GYo2l-0000pv-Ch for emacs-devel@gnu.org; Sat, 14 Oct 2006 14:15:31 -0400 Original-Received: from [192.114.186.66] (helo=romy.inter.net.il) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GYoBS-00045t-Ts for emacs-devel@gnu.org; Sat, 14 Oct 2006 14:24:31 -0400 Original-Received: from HOME-C4E4A596F7 (IGLD-80-230-160-108.inter.net.il [80.230.160.108]) by romy.inter.net.il (MOS 3.7.3-GA) with ESMTP id FZR27701 (AUTH halo1); Sat, 14 Oct 2006 20:15:17 +0200 (IST) Original-To: Andreas Schwab In-reply-to: (message from Andreas Schwab on Sat, 14 Oct 2006 19:50:01 +0200) 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:60745 Archived-At: > 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.