From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#71935: split-string-and-unquote mishandles dired-listing-switches with ' Date: Thu, 04 Jul 2024 19:10:17 +0300 Organization: LINKOV.NET Message-ID: <86a5ixqhd4.fsf@mail.linkov.net> References: <86tth5tztt.fsf@mail.linkov.net> <86zfqx8tnn.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10425"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 71935@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 04 18:15:21 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sPP79-0002ap-D3 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Jul 2024 18:15:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sPP6s-0003P5-QF; Thu, 04 Jul 2024 12:15:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sPP6q-0003OJ-En for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 12:15:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sPP6q-0005h1-6p for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 12:15:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sPP6s-0006Ke-KA for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 12:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jul 2024 16:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71935 X-GNU-PR-Package: emacs Original-Received: via spool by 71935-submit@debbugs.gnu.org id=B71935.172010967824272 (code B ref 71935); Thu, 04 Jul 2024 16:15:02 +0000 Original-Received: (at 71935) by debbugs.gnu.org; 4 Jul 2024 16:14:38 +0000 Original-Received: from localhost ([127.0.0.1]:42825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPP6T-0006JL-MC for submit@debbugs.gnu.org; Thu, 04 Jul 2024 12:14:38 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:32843) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPP6R-0006Is-Mh for 71935@debbugs.gnu.org; Thu, 04 Jul 2024 12:14:36 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 9F60BFF80A; Thu, 4 Jul 2024 16:14:05 +0000 (UTC) In-Reply-To: <86zfqx8tnn.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 04 Jul 2024 11:10:04 +0300") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288377 Archived-At: >> 1. (setopt dired-listing-switches "-al --block-size='1") >> 2. C-x d /tmp/* >> >> /tmp: >> wildcard * >> /bin/bash: -c: line 0: unexpected EOF while looking for matching `'' >> /bin/bash: -c: line 1: syntax error: unexpected end of file >> >> 3. (setopt dired-listing-switches "-al --block-size=\\'1") >> 4. C-x d /tmp/ >> >> Debugger entered--Lisp error: (error "Listing directory failed but ‘access-file’ worked") >> error("Listing directory failed but `access-file' worked") >> insert-directory("/tmp/" "--dired -N -al --block-size=\\'1" nil t) > > I think the part of insert-directory that deals with wildcard lacks > the call to shell-quote-argument here: > > ;; NB since switches is passed to the shell, be > ;; careful of malicious values, eg "-l;reboot". > ;; See eg dired-safe-switches-p. > (call-process > shell-file-name nil t nil > shell-command-switch > (concat (if (memq system-type '(ms-dos windows-nt)) > "" > "\\") ; Disregard Unix shell aliases! > insert-directory-program > " -d " > (if (stringp switches) > switches > (mapconcat #'identity switches " ")) > > Can you try running each switch through shell-quote-argument? This part of insert-directory is used only in case of 1-2 above, i.e. for wildcard '/tmp/*'. In this case the value of 'switches' is "--dired -N -al --block-size='1", and 'shell-quote-argument' returns "--dired\\ -N\\ -al\\ --block-size\\=\\'1" that fails. For the non-wildcard case of 3-4 above, this doesn't help either. Using (mapcar 'shell-quote-argument (split-string-and-unquote switches)) on ("--dired" "-N" "-al" "--block-size=\\'1") returns ("--dired" "-N" "-al" "--block-size\\=\\\\\\'1") that fails with /bin/ls: unrecognized option '--block-size\=\\\'1'