Subject: bug#1212: closed (Re: bug#7563: 23.2; `split-string-and-unquote' mis-documented / purpose unclear)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 11 Dec 2010 09:45:02 +0000

Your bug report

#1212: 23.0.60; split-string-and-unquote problems

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
1212: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1212
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#7563: 23.2; `split-string-and-unquote' mis-documented / purpose unclear
From: Eli Zaretskii <[email-masked]>
To: Dave Abrahams <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sat, 11 Dec 2010 11:50:35 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Sun, 05 Dec 2010 16:28:16 -0500
> From: Dave Abrahams <[email-masked]>
> Cc: 
> 
>        This function performs two types of quoting: enclosing a whole
>        string in double quotes `"..."', and quoting individual characters
>        with a backslash escape `\'.  The latter is also used in Lisp
>        strings, so this function can handle those as well.
> 
> 
> First problem: the last paragraph above is simply wrong.
> split-string-and-unquote doesn't perform any type of quoting; it
> un-quotes.

I changed "performs" to "supports".  Thanks for catching this.

> Second problem: the doc implies that a string that could be executed
> by the shell could be split into its constituent arguments by
> split-string-and-unquote, but in general, it cannot, e.g.:
> 
>   (split-string-and-unquote "'foo bar'") => ("'foo" "bar'")
>   (split-string-and-unquote "foo\\ bar") => ("foo" "bar")
> 
> I'm not sure what this function is really supposed to be for, but any
> implication that it properly handles conversion into shell arguments
> is highly misleading.  Some motivation should be given for proper use
> of split-string-and-unquote, or it should be deprecated.

This has come up before; see Bug #1212 and this thread:

  http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00431.html

The best explanation I can give you is that this function is for
taking minibuffer input and converting it to a list of string
arguments as required by call-process and start-process.  (I added
this information to the manual.)  Note that the documentation does not
mention "shell" anywhere.  You could also gain some insight by looking
at the users of this function.

With those changes, I'm closing this bug report (and 1212 as well),
because the issue has been already beaten to death in the above
discussion.

The changes I made are on the emacs-23 branch, btw, in case you want
to eyeball them.

>From [email-masked] Mon Oct 20 09:04:47 2008
Date: Mon, 20 Oct 2008 18:04:41 +0200
From: Eli Zaretskii <[email-masked]>
Subject: 23.0.60; split-string-and-unquote problems
To: [email-masked]

Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the [email-masked] mailing list.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

The function split-string-and-unquote is a great help in taking apart
shell command lines, but the values it returns seem incorrect in some
situations, at least from shell command quoting perspective:

 (split-string-and-unquote "foo\ bar")
    => ("foobar")                 [where's my blank?]
 (split-string-and-unquote "foo\\\ bar")
    => ("foo\\bar")               [where's my blank?]
 (split-string-and-unquote "foo\" \"bar")
    => ("foo" " " "bar")          [where's my blank]
 (split-string-and-unquote "foo\"*\"bar")
    => ("foo" "*" "bar")          [can't quote in the middle of a string?]
 (split-string-and-unquote "foo\\\"bar")
    => End of file during parsing [how do you quote a quote?]

Also, it doesn't support '..' quoting, which is quite frequent in
shell commands.

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
d:/gnu/emacs/etc/DEBUG for instructions.

In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
 of 2008-10-20 on HOME-C4E4A596F7
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1255
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  show-paren-mode: t
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<down> <down> <down> <down> <down> <down> C-SPC <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> M-w C-x b <return> C-y <return> M-: 
<up> <C-right> <C-right> <C-right> <C-right> <right> 
<right> <right> <right> <right> <right> <right> <delete> 
* <return> M-: <up> C-SPC C-e M-w <return> C-y SPC 
= > SPC C-x b <return> <down> <down> C-a C-SPC <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> M-w C-x b <return> C-y <return> M-: 
<up> <up> <up> <up> <down> <up> <up> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <delete> <delete> <delete> 
<delete> <delete> <delete> <delete> <delete> <delete> 
<delete> <delete> <delete> <delete> <delete> <delete> 
<delete> <delete> <delete> <delete> <delete> <delete> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <delete> <delete> <delete> 
<delete> <delete> <delete> <delete> <delete> <delete> 
<delete> <delete> <delete> <delete> <delete> <right> 
<right> C-SPC C-a M-w <return> C-y SPC = > SPC <down> 
<down> <down> <up> C-a M-: <up> <return> <C-right> 
<C-right> <C-right> <C-right> <C-right> <C-left> C-SPC 
<up> <down> C-e M-w <up> <left> C-y <right> M-: <up> 
<up> <up> <up> <C-right> <C-right> <C-right> <C-right> 
<C-right> \ <return> M-: <up> <C-right> <C-right> <C-right> 
<C-right> <C-right> \ <return> M-: <up> C-SPC C-e M-w 
<return> <up> <up> <up> <left> <return> C-y SPC = > 
SPC C-x b <return> <down> <down> <down> <down> <down> 
<down> <down> <left> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> <left> <left> <left> <left> 
<left> <left> <left> C-SPC <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> M-w C-x b <return> C-y C-x <up> <down> 
<up> M-x r e p o r t - e m a <tab> <return>

Recent messages:
("foo" "*" "bar") [2 times]
Mark set [3 times]
split-string-and-unquote: End of file during parsing
Mark set
split-string-and-unquote: End of file during parsing
Mark set [2 times]
("foo\\" "bar")
("foo\\bar") [2 times]
Mark set [3 times]
Scanning for dabbrevs...100%