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: Fri, 13 Oct 2006 23:26:01 +0200 Message-ID: <45300469.7030107@student.lu.se> References: <452517DC.5010007@student.lu.se> <45251C56.8010603@student.lu.se> <45265833.4030709@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1160774799 996 80.91.229.2 (13 Oct 2006 21:26:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 13 Oct 2006 21:26:39 +0000 (UTC) Cc: Thomas Link , Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 13 23:26:35 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 1GYUXr-0004Hl-8k for ged-emacs-devel@m.gmane.org; Fri, 13 Oct 2006 23:26:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GYUXq-0007t1-HF for ged-emacs-devel@m.gmane.org; Fri, 13 Oct 2006 17:26:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GYUXd-0007sf-To for emacs-devel@gnu.org; Fri, 13 Oct 2006 17:26:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GYUXd-0007sJ-0y for emacs-devel@gnu.org; Fri, 13 Oct 2006 17:26:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GYUXc-0007sF-Sd for emacs-devel@gnu.org; Fri, 13 Oct 2006 17:26:04 -0400 Original-Received: from [80.76.149.213] (helo=ch-smtp02.sth.basefarm.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GYUg9-0003q7-ET for emacs-devel@gnu.org; Fri, 13 Oct 2006 17:34:53 -0400 Original-Received: from c83-249-218-244.bredband.comhem.se ([83.249.218.244]:64023 helo=[192.168.123.121]) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.63) (envelope-from ) id 1GYUXZ-0000dG-9K; Fri, 13 Oct 2006 23:26:02 +0200 User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) Original-To: "Kim F. Storm" In-Reply-To: X-Scan-Result: No virus found in message 1GYUXZ-0000dG-9K. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1GYUXZ-0000dG-9K 6c9a163e5bea34b955e7de3ca2d650ec 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:60729 Archived-At: Kim F. Storm wrote: > Lennart Borgman writes: > > >> The author of filesets Thomas Link has replied to me that he currently >> does not use Emacs and cannot maintain filesets.el until that situation >> changes. >> >> I myself therefore suggest the following patch to filesets.el: >> > > Isolated, it looks ok, but if you look at filesets-quote, maybe > it should use shell-quote-argment too, and we should > use filesets-quote on buffer-file-name below. > > But it's too complex for me to follow the logic in filesets. > I just printed filesets.el - 40 pages ;-) Yes, I missed filesets-quote. It is used in filesets-get-quoted-selection. This is in turned used only in filesets-command: ("Grep <>" "grep" ("-n " filesets-get-quoted-selection " " "<>")) This is a shell command so in filesets-get-quoted-selection I think that shell-quote-argument should be used. filesets-quote is also used in filesets-run-cmd--repl-fn: ((equal arg "<>") (filesets-quote (buffer-file-name))) filesets-rum-cmd--repl-fn is only used in filesets-run-cmd where it is used two times. The first use of this function looks like this (cond ((stringp fn) (let* ((args (let ((txt "")) (dolist (this args txt) (setq txt (concat txt (filesets-run-cmd--repl-fn this (lambda (this) (if (equal txt "") "" " ") (format "%s" this)))))))) (cmd (concat fn " " args))) (filesets-cmd-show-result cmd (shell-command-to-string cmd)))) What is intended is probably something like this: (cond ((stringp fn) (let* ((args (let ((txt "")) (dolist (this args txt) (setq txt (concat txt (if (equal txt "") "" " ") (shell-quote-argument this)))))) (setq fn (shell-quote-argument fn)) (cmd (concat fn " " args))) (filesets-cmd-show-result cmd (shell-command-to-string cmd)))) Coming this far I looked a bit more carefully at filesets-run-cmd. And I do not understand what it is doing. The code below is from this function. I have however replaced the name of the loop variable from "this" to "file". Further down in the function neither "file" or "buffer" is used. Seems strange to me. Can someone explain what the code does or what it was supposed to do? : (dolist (file files nil) (save-excursion (save-restriction (let ((buffer (filesets-find-file file))) (when buffer (goto-char (point-min)) BTW the optional argument in (defun filesets-run-cmd--repl-fn (arg &optional format-fn) should not be optional I think. Leaving it out will result in (funcall nil ...). > >> Index: filesets.el >> =================================================================== >> RCS file: /cvsroot/emacs/emacs/lisp/filesets.el,v >> retrieving revision 1.29 >> diff -c -r1.29 filesets.el >> *** filesets.el 13 Aug 2006 17:05:12 -0000 1.29 >> --- filesets.el 6 Oct 2006 13:15:12 -0000 >> *************** >> *** 1701,1707 **** >> ok) >> t))) >> (when ok >> ! (let ((cmd (format txt (buffer-file-name)))) >> (message "Filesets: %s" cmd) >> (filesets-cmd-show-result cmd >> (shell-command-to-string cmd)))))) >> --- 1701,1707 ---- >> ok) >> t))) >> (when ok >> ! (let ((cmd (format txt (shell-quote-argument (buffer-file-name))))) >> (message "Filesets: %s" cmd) >> (filesets-cmd-show-result cmd >> (shell-command-to-string cmd)))))) >> > > -- lennart.borgman.073@student.lu.se http://OurComments.org/blog/