unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15334: 24.3; shell-quote-argument not considering non-ascii paths
@ 2013-09-11  3:27 Haoyang Xu
  2013-09-11  8:11 ` Andreas Schwab
  2013-09-13 13:39 ` Kenichi Handa
  0 siblings, 2 replies; 6+ messages in thread
From: Haoyang Xu @ 2013-09-11  3:27 UTC (permalink / raw)
  To: 15334

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

--text follows this line--
I wrote a custom function that let me preview a Markdown buffer in
Marked, which utilizes shell-quote-argument to export the path to the
file being edited in Emacs to Marked.app. It works well until it
encounters file names or paths with Chinese characters. The Chinese
characters are wrongfully escaped. For example:

    (shell-quote-argument "/Users/user/中文目录/中文file.txt")
    evals to
    "/Users/user/\\中\\文\\目\\录/\\中\\文file.txt"

The shell-quote-argument function yields the same output under a new
emacs instance started with `emacs -q`, so this should not be related to
my configuration.

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.

Shouldn't the regexp in the function be more discriminative and
recognize, say, unicode characters allowed in file names and paths? I think
very few people use (or know) any shell that recognize a unicode smiley
(U+263A) as a command, but many use a language they speak to name
files.


In GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
 of 2013-03-13 on bob.porkrind.org
Windowing system distributor `Apple', version 10.3.1187
Configured using:
 `configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin'
 '--with-ns' 'build_alias=i686-apple-darwin'
 'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.7
 -isystem
 /Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/
 -F/Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks''

Important settings:
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: EL

Minor modes in effect:
  rainbow-mode: t
  rainbow-delimiters-mode: t
  elisp-slime-nav-mode: t
  guru-mode: t
  global-linum-mode: t
  linum-mode: t
  evil-mode: t
  evil-local-mode: t
  erc-truncate-mode: t
  erc-track-mode: t
  erc-spelling-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  which-function-mode: t
  winner-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  eldoc-mode: t
  whitespace-mode: t
  projectile-global-mode: t
  projectile-mode: t
  flyspell-mode: t
  flx-ido-mode: t
  ido-ubiquitous-mode: t
  volatile-highlights-mode: t
  global-hl-line-mode: t
  show-paren-mode: t
  shell-dirtrack-mode: t
  recentf-mode: t
  savehist-mode: t
  smartparens-global-mode: t
  smartparens-mode: t
  global-auto-revert-mode: t
  delete-selection-mode: t
  prelude-global-mode: t
  prelude-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<down-mouse-1> <mouse-1> <down-mouse-1> <mouse-1> (
<down-mouse-1> <mouse-1> ) C-x C-e <help-echo> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo>
<down-mouse-1> <help-echo> <help-echo> <drag-mouse-1>
C-h e <wheel-down> <double-wheel-down> <triple-wheel-down>
<triple-wheel-down> <down-mouse-1> <mouse-movement>
<mouse-movement> <s-drag-mouse-1> s-c q <down-mouse-1>
<drag-mouse-1> C-x b <return> <escape> C-a C-k C-k
C-k C-x C-s <up> <up> <up> <down> <down> <down-mouse-1>
<mouse-movement> <mouse-movement> <drag-mouse-1> s-c
<help-echo> <down-mouse-1> <mouse-1> o <return> k e
<backspace> <backspace> k e j <backspace> <backspace>
<backspace> 可 见 , C-x C-s C-x 1 <escape> : w <return>
M-x <up> <down> <up> <down> <return> C-h f p r e v
i e w - <return> <help-echo> <down-mouse-1> <mouse-2>
<help-echo> C-h f s h e l l - q u o t <return> <help-echo>
<down-mouse-1> <mouse-2> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <up> <up> <up> <up> <up> <down> <down>
<down> <down> <down> <down> <down> <down> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <down>
<down> <down> <down> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <down-mouse-1> <mouse-1> M-x r e p o r t <ret
urn>

Recent messages:
Saving file /Users/snakehsu/Dropbox/Office
Work/OngoingProjects/HFC削减对策研究/01-北美提案研究/03-批评分析/北美提案评价与分析.md...
Wrote /Users/snakehsu/Dropbox/Office
Work/OngoingProjects/HFC削减对策研究/01-北美提案研究/03-批评分析/北美提案评价与分析.md<http://xn--jhqyvo7ee5au92cxefylb135i57w.md>
Saving file /Users/snakehsu/Dropbox/Office
Work/OngoingProjects/HFC削减对策研究/01-北美提案研究/03-批评分析/北美提案评价与分析.md...
Wrote /Users/snakehsu/Dropbox/Office
Work/OngoingProjects/HFC削减对策研究/01-北美提案研究/03-批评分析/北美提案评价与分析.md<http://xn--jhqyvo7ee5au92cxefylb135i57w.md>
(No changes need to be saved)
Type C-w C-o to delete the help window.
Type "q" in help window to restore its previous buffer.
uncompressing subr.el.gz...done
compressing flycheck-subr.el.gz...done
compressing subr.el.gz...done

Load-path shadows:
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-w3m hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-w3m
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-timer hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-timer
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-table hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-table
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-src hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-src
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-rmail hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-rmail
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-protocol hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-protocol
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-plot hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-plot
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-pcomplete hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-pcomplete
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-mouse hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-mouse
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-mobile hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-mobile
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-mhe hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-mhe
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-macs hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-macs
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-loaddefs hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-loaddefs
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-list hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-list
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-irc hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-irc
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-install hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-install
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-inlinetask hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-inlinetask
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-info hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-info
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-indent hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-indent
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-id hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-id
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-habit hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-habit
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-gnus hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-gnus
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-footnote hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-footnote
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-feed hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-feed
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-faces hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-faces
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-eshell hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-eshell
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-entities hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-entities
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-element hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-element
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-docview hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-docview
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-datetree hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-datetree
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-ctags hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-ctags
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-crypt hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-crypt
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-compat hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-compat
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-colview hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-colview
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-clock hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-clock
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-capture hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-capture
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-bibtex hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-bibtex
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-bbdb hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-bbdb
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-attach hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-attach
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-archive hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-archive
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-agenda hides
/Applications/Emacs.app/Contents/Resources/lisp/org/org-agenda
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-tangle hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-tangle
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-table hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-table
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-sqlite hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-sqlite
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-sql hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-sql
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-shen hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-shen
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-sh hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-sh
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-screen hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-screen
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-scheme hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-scheme
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-scala hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-scala
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-sass hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-sass
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ruby hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-ruby
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ref hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-ref
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-R hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-R
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-python hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-python
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-plantuml hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-plantuml
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-picolisp hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-picolisp
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-perl hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-perl
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-org hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-org
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-octave hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-octave
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ocaml hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-ocaml
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-mscgen hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-mscgen
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-maxima hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-maxima
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-matlab hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-matlab
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-lob hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-lob
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-lisp hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-lisp
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-lilypond hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-lilypond
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ledger hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-ledger
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-latex hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-latex
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-keys hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-keys
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-js hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-js
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-java hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-java
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-io hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-io
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-haskell hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-haskell
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-gnuplot hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-gnuplot
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-fortran hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-fortran
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-exp hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-exp
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-eval hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-eval
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-emacs-lisp hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-emacs-lisp
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-dot hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-dot
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ditaa hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-ditaa
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-css hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-css
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-comint hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-comint
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-clojure hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-clojure
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-calc hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-calc
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-C hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-C
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-awk hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-awk
/Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-asymptote hides
/Applications/Emacs.app/Contents/Resources/lisp/org/ob-asymptote
/Users/snakehsu/.emacs.d/elpa/magit-20130722.239/.dir-locals hides
/Applications/Emacs.app/Contents/Resources/lisp/gnus/.dir-locals

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mail-utils jka-compr helm-imenu
vc-git debug executable markdown-mode ffap url-parse url-vars
rainbow-mode rainbow-delimiters elisp-slime-nav guru-mode color
the-org-mode-expansions org org-macro org-footnote org-pcomplete
org-list org-faces org-entities noutline outline ob-emacs-lisp ob
ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint
ob-core ob-eval org-compat org-macs org-loaddefs cal-menu calendar
cal-loaddefs linum evil evil-integration evil-maps evil-commands
evil-types evil-search evil-ex evil-macros evil-repeat evil-states
evil-core evil-common rect evil-digraphs evil-vars zen-and-art-theme
prelude-xml nxml-mode-expansions html-mode-expansions rng-nxml rng-valid
rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn
nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc
xmltok prelude-scheme prelude-perl prelude-org prelude-js prelude-erc
erc-truncate erc-track erc-match erc-autoaway erc-spelling erc-notify
erc-networks erc-log erc-goodies erc erc-backend erc-compat
prelude-emacs-lisp prelude-lisp prelude-c prelude-programming flycheck
find-func help-mode rx which-func imenu prelude-osx exec-path-from-shell
prelude-global-keybindings key-chord prelude-editor winner undo-tree
diff esh-var esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg eldoc
esh-groups eshell esh-module esh-mode esh-util re-builder whitespace
midnight ediff-merg ediff-diff ediff-wind ediff-help ediff-util
ediff-mult ediff-init ediff dired-x helm-projectile helm-buffers
helm-grep helm-regexp helm-elscreen helm-utils dired helm-locate
helm-config helm-aliases helm-misc helm projectile grep compile s
bookmark pp expand-region text-mode-expansions er-basic-expansions
expand-region-custom expand-region-core flyspell ispell smex flx-ido flx
ido-ubiquitous ido etags volatile-highlights hl-line paren windmove
tramp-cache tramp-sh tramp tramp-compat auth-source gnus-util mm-util
mail-prsvr password-cache tramp-loaddefs shell pcomplete comint
ansi-color ring format-spec recentf tree-widget wid-edit savehist
saveplace uniquify diminish smartparens-config smartparens warnings
autorevert delsel prelude-mode easy-mmode edmacro kmacro prelude-core
advice help-fns advice-preload dash thingatpt prelude-ui zenburn-theme
prelude-packages ace-jump-mode-autoloads ack-and-a-half-autoloads
color-theme-autoloads diminish-autoloads elisp-slime-nav-autoloads
evil-paredit-autoloads evil-autoloads exec-path-from-shell-autoloads
expand-region-autoloads flx-ido-autoloads flx-autoloads
flycheck-autoloads gist-autoloads gh-autoloads eieio byte-opt bytecomp
byte-compile cconv git-auto-commit-mode-autoloads
git-commit-mode-autoloads gitconfig-mode-autoloads
gitignore-mode-autoloads grizzl-autoloads guru-mode-autoloads
helm-projectile-autoloads helm-autoloads ido-ubiquitous-autoloads
ir-black-theme-autoloads key-chord-autoloads logito-autoloads
magit-autoloads markdown-mode-autoloads mustache-mode-autoloads
org-trello-autoloads org-autoloads info easymenu paredit-autoloads
pcache-autoloads php-mode-autoloads powerline-autoloads powerline
powerline-separators powerline-themes projectile-autoloads
rainbow-delimiters-autoloads rainbow-mode-autoloads request-autoloads
ruby-end-autoloads s-autoloads smartparens-autoloads dash-autoloads
finder-inf smex-autoloads solarized-theme-autoloads undo-tree-autoloads
volatile-highlights-autoloads yasnippet-autoloads
zen-and-art-theme-autoloads zenburn-theme-autoloads
zencoding-mode-autoloads package cl-macs gv cl cl-lib time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset
image regexp-opt fringe tabulated-list newcomment lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process ns multi-tty emacs)

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15334: 24.3; shell-quote-argument not considering non-ascii paths
  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-13 13:39 ` Kenichi Handa
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2013-09-11  8:11 UTC (permalink / raw)
  To: Haoyang Xu; +Cc: 15334

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

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15334: Fwd: bug#15334: 24.3; shell-quote-argument not considering non-ascii paths
       [not found]   ` <CAGHDjn6egD84niYYK+ZaBqawTXc8Z=xBtZMtyNosDTxGw4EMUg@mail.gmail.com>
@ 2013-09-12  5:09     ` Haoyang Xu
  2013-09-12  8:41       ` Andreas Schwab
  0 siblings, 1 reply; 6+ messages in thread
From: Haoyang Xu @ 2013-09-12  5:09 UTC (permalink / raw)
  To: 15334

[-- 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 --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15334: Fwd: bug#15334: 24.3; shell-quote-argument not considering non-ascii paths
  2013-09-12  5:09     ` bug#15334: Fwd: " Haoyang Xu
@ 2013-09-12  8:41       ` Andreas Schwab
  2013-09-12  9:56         ` Haoyang Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2013-09-12  8:41 UTC (permalink / raw)
  To: Haoyang Xu; +Cc: 15334

Haoyang Xu <snakehsu@gmail.com> writes:

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

No, it doesn't.

>   $ ls ~/Dropbox/Office\ Work/\\参\\考\\资\\料/

This is not what shell-quote-argument returns.

ELISP> (shell-quote-argument "~/Dropbox/Office Work/参考资料/")
"\\~/Dropbox/Office\\ Work/\\参\\考\\资\\料/"

There is only one backslash before each quoted character.

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15334: Fwd: bug#15334: 24.3; shell-quote-argument not considering non-ascii paths
  2013-09-12  8:41       ` Andreas Schwab
@ 2013-09-12  9:56         ` Haoyang Xu
  0 siblings, 0 replies; 6+ messages in thread
From: Haoyang Xu @ 2013-09-12  9:56 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 15334

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

On Thu, Sep 12, 2013 at 4:41 PM, Andreas Schwab <schwab@suse.de> wrote:
>
> Haoyang Xu <snakehsu@gmail.com> writes:
>
> > 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.
>
> No, it doesn't.
>
> >   $ ls ~/Dropbox/Office\ Work/\\参\\考\\资\\料/
>
> This is not what shell-quote-argument returns.
>
> ELISP> (shell-quote-argument "~/Dropbox/Office Work/参考资料/")
> "\\~/Dropbox/Office\\ Work/\\参\\考\\资\\料/"
>
>
> There is only one backslash before each quoted character.


You are again right :) My bad, I didn't set my environment properly. I need
to ensure Emacs send the arguments to shell in UTF-8 coding, by either

      (setq default-process-coding-system '(utf-8 . utf-8))
   or
      (set-language-environment "UTF-8")

Then it works.

Sorry for letting you chase the ghost. Please accept my apology and thanks.


Best Regards,

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: 1639 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15334: 24.3; shell-quote-argument not considering non-ascii paths
  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
@ 2013-09-13 13:39 ` Kenichi Handa
  1 sibling, 0 replies; 6+ messages in thread
From: Kenichi Handa @ 2013-09-13 13:39 UTC (permalink / raw)
  To: Haoyang Xu; +Cc: 15334

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=iso-2022-jp-2, Size: 947 bytes --]

In article <CAGHDjn4=QmAgCyouB9=QUGBycrh_CAMJhqM0U8R5UikC8kDV5g@mail.gmail.com>, Haoyang Xu <snakehsu@gmail.com> writes:

>     (shell-quote-argument "/Users/user/^[$BCfJ8L\^[$AB<^[(B/^[$BCfJ8^[(Bfile.txt")
>     evals to
>     "/Users/user/\\^[$BCf^[(B\\^[$BJ8^[(B\\^[$BL\^[(B\\^[$AB<^[(B/\\^[$BCf^[(B\\^[$BJ8^[(Bfile.txt"

> The shell-quote-argument function yields the same output under a new
> emacs instance started with `emacs -q`, so this should not be related to
> my configuration.

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

I agree that such excapes are superfluous, but my bash
recognizes it correctly (my locale is ja_JP.UTF-8).

% mkdir -p \^[$BCf^[(B\^[$BJ8^[(B\^[$BL\^[(B\^[$AB<^[(B/\^[$BCf^[(B\^[$BJ8^[(Bfile.txt
% ls \^[$BCf^[(B\^[$BJ8^[(B\^[$BL\^[(B\^[$AB<^[(B
^[$BCfJ8^[(Bfile.txt/

---
Kenichi Handa
handa@gnu.org





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-09-13 13:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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     ` bug#15334: Fwd: " Haoyang Xu
2013-09-12  8:41       ` Andreas Schwab
2013-09-12  9:56         ` Haoyang Xu
2013-09-13 13:39 ` Kenichi Handa

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