From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#71935: split-string-and-unquote mishandles dired-listing-switches with ' Date: Thu, 04 Jul 2024 11:10:04 +0300 Message-ID: <86zfqx8tnn.fsf@gnu.org> References: <86tth5tztt.fsf@mail.linkov.net> 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="26496"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71935@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 04 10:11:18 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 1sPHYj-0006aq-Fr for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Jul 2024 10:11:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sPHYU-0002Ae-U8; Thu, 04 Jul 2024 04:11: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 1sPHYT-00027x-1I for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 04:11:01 -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 1sPHYS-0005rz-MK for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 04:11:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sPHYU-0006MU-FC for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 04:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jul 2024 08:11: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.172008061824393 (code B ref 71935); Thu, 04 Jul 2024 08:11:02 +0000 Original-Received: (at 71935) by debbugs.gnu.org; 4 Jul 2024 08:10:18 +0000 Original-Received: from localhost ([127.0.0.1]:41435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPHXl-0006LN-TY for submit@debbugs.gnu.org; Thu, 04 Jul 2024 04:10:18 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:33068) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPHXj-0006L4-1i for 71935@debbugs.gnu.org; Thu, 04 Jul 2024 04:10:16 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sPHXa-0005aL-Dt; Thu, 04 Jul 2024 04:10:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=f2HNcj1ddVwIzY5KQLZdGJwBqTNTeDY1rDb3A++zlKQ=; b=bMZoOw6AQ9+kN3FCQ4RA C6SuTq7Fznl1VcAuW2axXkXxi3nSoRNABR8uP6BbyTkBh7blgJp/P8DtAXMxAf1ATpmKb03Gme/AY cZOy+xpaaKKiDN/g8Uhc5HSWpbkr592jbkEE15whW33FdNAr69/UztpOHYTfhiPYY2IkgViTd9ena KW6Bvtnb37rsswvLanAraV2DRPFOlwTKKWmOzXVI1BUnEZ0cYMu1FAsDXji1OXOZ4Dl9pKfgS7n8W DKIqqHROlK66kvQ2X4ymCpSAQIWAq/RUUdXMUmrrFOsRPSPft6GTYICPIVPAT0GIS6KCh+M0/OPjp 0qGsT7KRBLtT8A==; In-Reply-To: <86tth5tztt.fsf@mail.linkov.net> (message from Juri Linkov on Thu, 04 Jul 2024 09:51:10 +0300) 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:288360 Archived-At: > From: Juri Linkov > Date: Thu, 04 Jul 2024 09:51:10 +0300 > > 0. emacs -Q > 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) > dired-insert-directory("/tmp/" "-al --block-size=\\'1" nil nil t) > dired-readin-insert() > dired-readin() > dired-internal-noselect("/tmp/" nil) > dired-noselect("/tmp/" nil) > dired("/tmp/" nil) > funcall-interactively(dired "/tmp/" nil) > command-execute(dired) > > because 'split-string-and-unquote' in 'insert-directory' > doesn't turn "--block-size=\\'1" into "--block-size='1". 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?