all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Haoyang Xu <snakehsu@gmail.com>
To: 15334@debbugs.gnu.org
Subject: bug#15334: Fwd: bug#15334: 24.3; shell-quote-argument not considering non-ascii paths
Date: Thu, 12 Sep 2013 13:09:31 +0800	[thread overview]
Message-ID: <CAGHDjn4rwGvTBv5shmewvt3V3Kstbn-=APsE0maXUNZceB=-4g@mail.gmail.com> (raw)
In-Reply-To: <CAGHDjn6egD84niYYK+ZaBqawTXc8Z=xBtZMtyNosDTxGw4EMUg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1853 bytes --]

On Wed, Sep 11, 2013 at 4:11 PM, Andreas Schwab <schwab@suse.de> wrote:

> Haoyang Xu <snakehsu@gmail.com> writes:
>
> > A quick look of the function in question shows that it just escapes all
> > non-ASCII characters, and the escaped Chinese characters cannot be
> > correctly recognized by either bash or zsh.
>
> How does it fail?  Quoting a non-special character should be a no-op to
> the shell (it will just ignore the quote).
>
You are absolutely right. The problem is, shell-quote-argument is trying to
escape characters that are [^-0-9a-zA-Z_./\n] with \\\&, double escape
character, thanks to this part of the function, I think:

(t
    (if (equal argument "")
        "''"
      ;; Quote everything except POSIX filename characters.
      ;; This should be safe enough even for really weird shells.
      (replace-regexp-in-string
       "\n" "'\n'"
       (replace-regexp-in-string "[^-0-9a-zA-Z_./\n]" "\\\\\\&" argument))))
   ))

Although this works for whitespaces and maybe some other characters (and I
don't know why), the resulted string will have _two_ escape characters in
front of every Chinese character. The shell gets this string, and thinks
every Chinese character have one unescaped \ in front of them as part of
the file name, causing a no such file error, it's just like I write my
command as following:

  $ ls ~/Dropbox/Office\ Work/\\参\\考\\资\\料/
  ls: /Users/snakehsu/Dropbox/Office Work/\参\考\资\料/: No such file or
directory

I believe the developers have reasons to write the replace statement like
this, but it does cause problem for a lot of file names.

Haoyang

>
> Andreas.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>

[-- Attachment #2: Type: text/html, Size: 3127 bytes --]

  parent reply	other threads:[~2013-09-12  5:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11  3:27 bug#15334: 24.3; shell-quote-argument not considering non-ascii paths Haoyang Xu
2013-09-11  8:11 ` Andreas Schwab
     [not found]   ` <CAGHDjn6egD84niYYK+ZaBqawTXc8Z=xBtZMtyNosDTxGw4EMUg@mail.gmail.com>
2013-09-12  5:09     ` Haoyang Xu [this message]
2013-09-12  8:41       ` bug#15334: Fwd: " Andreas Schwab
2013-09-12  9:56         ` Haoyang Xu
2013-09-13 13:39 ` Kenichi Handa

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='CAGHDjn4rwGvTBv5shmewvt3V3Kstbn-=APsE0maXUNZceB=-4g@mail.gmail.com' \
    --to=snakehsu@gmail.com \
    --cc=15334@debbugs.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.