From: Eli Zaretskii <eliz@gnu.org>
To: Juri Linkov <juri@linkov.net>
Cc: 71935@debbugs.gnu.org
Subject: bug#71935: split-string-and-unquote mishandles dired-listing-switches with '
Date: Thu, 04 Jul 2024 20:56:11 +0300 [thread overview]
Message-ID: <868qyh82is.fsf@gnu.org> (raw)
In-Reply-To: <86a5ixqhd4.fsf@mail.linkov.net> (message from Juri Linkov on Thu, 04 Jul 2024 19:10:17 +0300)
> From: Juri Linkov <juri@linkov.net>
> Cc: 71935@debbugs.gnu.org
> Date: Thu, 04 Jul 2024 19:10:17 +0300
>
> >> 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.
I meant to call shell-quote-argument on each option, before they are
concatenated.
> 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'
Why did you use "--block-size=\\'1"? My idea is that the quoting
should not come from the user.
next prev parent reply other threads:[~2024-07-04 17:56 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 [this message]
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
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=868qyh82is.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=71935@debbugs.gnu.org \
--cc=juri@linkov.net \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).