From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 71935@debbugs.gnu.org
Subject: bug#71935: split-string-and-unquote mishandles dired-listing-switches with '
Date: Fri, 05 Jul 2024 09:48:39 +0300 [thread overview]
Message-ID: <86sewoqqpk.fsf@mail.linkov.net> (raw)
In-Reply-To: <86tth56kgw.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 04 Jul 2024 22:11:27 +0300")
>> > @@ -8195,9 +8193,11 @@ insert-directory
>> > - (if (stringp switches)
>> > - switches
>> > - (mapconcat #'identity switches " "))
>> > + (mapconcat #'shell-quote-argument
>> > + (if (stringp switches)
>> > + (split-string-and-unquote switches)
>> > + switches)
>> > + " ")
>>
>> Thanks, that's what I had in mind. Please install on the emacs-30
>> branch.
>
> On second thought: could there be options that include shell
> wildcards, which therefore should not be quoted? If so, perhaps
> instead of shell-quote-argument we should use
> shell-quote-wildcard-pattern?
Indeed, there are ls switches that use wildcards, e.g.
‘--hide=PATTERN’ and ‘--ignore=PATTERN’. But it seems
they are ignored anyway while using wildcards with 'ls -d',
so I can't test them. What I can confirm only is that with
1. (setopt dired-listing-switches "-al --block-size='1 --ignore=system*")
2. C-x d /tmp/s*
the switches are correctly quoted by 'shell-quote-wildcard-pattern':
"ls -d --dired -N -al --block-size=\\'1 --ignore=system* -- s*"
diff --git a/lisp/files.el b/lisp/files.el
index 042b8e2d515..e69dfb22a5f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -8195,9 +8193,15 @@ insert-directory
"\\") ; Disregard Unix shell aliases!
insert-directory-program
" -d "
- (if (stringp switches)
- switches
- (mapconcat #'identity switches " "))
+ ;; Quote switches that require quoting
+ ;; such as "--block-size='1". But don't
+ ;; quote switches that use patterns
+ ;; such as "--ignore=PATTERN" (bug#71935).
+ (mapconcat #'shell-quote-wildcard-pattern
+ (if (stringp switches)
+ (split-string-and-unquote switches)
+ switches)
+ " ")
" -- "
;; Quote some characters that have
;; special meanings in shells; but
next prev parent reply other threads:[~2024-07-05 6:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 6:51 bug#71935: split-string-and-unquote mishandles dired-listing-switches with ' Juri Linkov
2024-07-04 8:10 ` Eli Zaretskii
2024-07-04 16:10 ` Juri Linkov
2024-07-04 17:56 ` Eli Zaretskii
2024-07-04 18:12 ` Juri Linkov
2024-07-04 18:34 ` Eli Zaretskii
2024-07-04 18:54 ` Juri Linkov
2024-07-04 19:03 ` Eli Zaretskii
2024-07-04 19:11 ` Eli Zaretskii
2024-07-05 6:48 ` Juri Linkov [this message]
2024-07-05 7:43 ` Eli Zaretskii
2024-07-07 6:57 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86sewoqqpk.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=71935@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.