Subject: bug#71935: split-string-and-unquote mishandles dired-listing-switches with '

From: Juri Linkov <[email-masked]>
Date: Thu, 04 Jul 2024 21:12:01 +0300

>> >> 1. (setopt dired-listing-switches "-al --block-size='1")
>> >> 2. C-x d /tmp/*
>> 
>> 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.

But switches are never unconcatenated in a list,
they come from the string:

  (setopt dired-listing-switches "-al --block-size='1")

>> 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.

If the wildcard case above could be fixed, then there is no need
to use "--block-size=\\'1".