Subject: Re: bug#2607: 23.0.90; `system-type' test in `shell-quote-wildcard-pattern'

From: Stefan Monnier <[email-masked]>
Date: Tue, 10 Mar 2009 22:02:30 -0400

> Wonderful, isn't it? code that solves a non-trivial problem by doing
> absolutely nothing?

Awesome!

> Seriously, though: that function does do what the doc string promises,
> on Unix as well as on DOS/Windows.  It does that by not quoting the
> Unix quote character: the backslash itself.  Thus
>   (shell-quote-wildcard-pattern "'foo*")
>    => "\\'foo*"
> but
>   (shell-quote-wildcard-pattern "foo\\*")
>    => "foo\\*"
> Perhaps we should make the doc string less of a riddle by saying
> explicitly that "quote characters" in this context means " on Windows
> and backslash on Unix.

OK, I now kind of understand what it does, but...

>> And furthermore, even seeing the code, I don't understand what is
>> this special case supposed to be used for.
> Sorry, I don't understand: what special case did you have in mind?

... why is this behavior useful?
I.e. when is it useful to have this function be idempotent?
[... thinking ...]
I think I understand: idempotency is actually not important, and is not
really what is meant by the 2 lines.
Indeed (shell-quote-wildcard-pattern "\\'foo*") => "\\\\'foo*"
so it's not idempotent: \ can be used to escape [*?\] but not [;<>&|()'"#$].

How 'bout something like:

   Quote characters special to the shell in pattern, leave wildcards alone.

   PATTERN should be a file-name wildcard pattern suitable for the
   underlying filesystem.  PATTERN can use \ under Unix and " in Windows
   to quote wildcard characters.

-- Stefan