* Re: combine-and-quote-strings
[not found] <mailman.502.1428836406.904.help-gnu-emacs@gnu.org>
@ 2015-04-12 10:55 ` Pascal J. Bourguignon
2015-04-12 16:15 ` combine-and-quote-strings Emanuel Berg
2015-04-14 18:54 ` combine-and-quote-strings Philipp Stephani
0 siblings, 2 replies; 6+ messages in thread
From: Pascal J. Bourguignon @ 2015-04-12 10:55 UTC (permalink / raw)
To: help-gnu-emacs
Philipp Stephani <p.stephani2@gmail.com> writes:
> Hi,
>
> the Lisp manual explains (in the section "Shell Arguments"):
>
> The following two functions are useful for combining a list of
> individual command-line argument strings into a single string,
>
> This is about combine-and-quote-strings (and
> split-strings-and-unquote). However, combine-and-quote-strings can't
> really be used for that purpose because it doesn't quote many shell
> metacharacters. The correct way to shell-quote a list of arguments is
>
> (mapconcat #'shell-quote-argument ARGS " ")
>
> Should combine-and-quote-strings be reimplemented in terms of
> shell-quote-argument? The current definition doesn't seem to be optimal
> for shell quoting because many inputs aren't properly quoted.
>
> Or is combine-and-quote-strings not intended for shell quoting at all
> and the documentation should be adapted?
The documentation ofcombine-and-quote-strings doesn't mention shell
quoting at all.
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
^ permalink raw reply [flat|nested] 6+ messages in thread
* combine-and-quote-strings
@ 2015-04-12 10:59 Philipp Stephani
0 siblings, 0 replies; 6+ messages in thread
From: Philipp Stephani @ 2015-04-12 10:59 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
the Lisp manual explains (in the section "Shell Arguments"):
The following two functions are useful for combining a list of
individual command-line argument strings into a single string,
This is about combine-and-quote-strings (and
split-strings-and-unquote). However, combine-and-quote-strings can't
really be used for that purpose because it doesn't quote many shell
metacharacters. The correct way to shell-quote a list of arguments is
(mapconcat #'shell-quote-argument ARGS " ")
Should combine-and-quote-strings be reimplemented in terms of
shell-quote-argument? The current definition doesn't seem to be optimal
for shell quoting because many inputs aren't properly quoted.
Or is combine-and-quote-strings not intended for shell quoting at all
and the documentation should be adapted?
Thanks,
Philipp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: combine-and-quote-strings
2015-04-12 10:55 ` combine-and-quote-strings Pascal J. Bourguignon
@ 2015-04-12 16:15 ` Emanuel Berg
2015-04-12 18:04 ` combine-and-quote-strings Drew Adams
2015-04-14 18:54 ` combine-and-quote-strings Philipp Stephani
1 sibling, 1 reply; 6+ messages in thread
From: Emanuel Berg @ 2015-04-12 16:15 UTC (permalink / raw)
To: help-gnu-emacs
"Pascal J. Bourguignon" <pjb@informatimago.com>
writes:
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
>> ... the Lisp manual explains (in the section "Shell
>> Arguments"): The following two functions are useful
>> for combining a list of individual command-line
>> argument strings into a single string, This is
>> about combine-and-quote-strings (and
>> split-strings-and-unquote). However,
>> combine-and-quote-strings can't really be used for
>> that purpose because it doesn't quote many shell
>> metacharacters. The correct way to shell-quote
>> a list of arguments is (mapconcat
>> #'shell-quote-argument ARGS " ") Should
>> combine-and-quote-strings be reimplemented in terms
>> of shell-quote-argument? The current definition
>> doesn't seem to be optimal for shell quoting
>> because many inputs aren't properly quoted. Or is
>> combine-and-quote-strings not intended for shell
>> quoting at all and the documentation should
>> be adapted?
>
> The documentation of combine-and-quote-strings
> doesn't mention shell quoting at all.
Here is what the on-line help says - and I quote :)
(combine-and-quote-strings STRINGS &optional
SEPARATOR)
Concatenate the STRINGS, adding the SEPARATOR
(default " "). This tries to quote the strings to
avoid ambiguity such that
(split-string-and-unquote
(combine-and-quote-strings strs)) == strs Only
some SEPARATORs will work properly.
Here is what the Lisp manual say:
This function concatenates LIST-OF-STRINGS into
a single string, quoting each string as
necessary. It also sticks the SEPARATOR string
between each pair of strings; if SEPARATOR is
omitted or ‘nil’, it defaults to ‘" "’.
The return value is the resulting string.
The strings in LIST-OF-STRINGS that need quoting
are those that include SEPARATOR as their
substring. Quoting a string encloses it in double
quotes ‘"…"’. In the simplest case, if you are
consing a command from the individual
command-line arguments, every argument that
includes embedded blanks will be quoted.
So no, it doesn't mention shell quoting (or the
quoting of metachars as the OP puts it) but
1) I don't think the on-line help is clear and
2) the Lisp manual is clear (or more clear at least)
save for the last sentence: the "individual
command-line arguments"...
In particular, both should make clear that quoting is
not the quoting of shell (or otherwise) metachars, nor
the "Emacs quoting" (x vs. 'x) but instead the
insertion of double-quotation marks as substring
delimiters for each substring - marks that have to be
quoted to separate them from the identical delimiters
of the outer, "real" string - in the case where the
delimiter between the substrings also occurs within
the substrings.
You see? Wasn't that crystal clear?
Besides, if you don't agree that it isn't clear
(either piece of documentation), I have proof I'm
right, namely the OP which did the opposite of what
most people do - instead of ignoring the documentation
and still getting it to work somehow, he read the
documentation and it made him even more confused :)
Anyway here is how it works:
(combine-and-quote-strings
'("one two three four"
"shamen knocking at the door")) ; implicit separator is " ", so quote "strings"
; => "\"one two three four\" \"shamen knocking at the door\""
(combine-and-quote-strings
'("one two three four"
"shamen knocking at the door") ".") ; separator is "." so no quoting
; => "one two three four.shamen knocking at the door"
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: combine-and-quote-strings
2015-04-12 16:15 ` combine-and-quote-strings Emanuel Berg
@ 2015-04-12 18:04 ` Drew Adams
2015-04-14 19:06 ` combine-and-quote-strings Philipp Stephani
0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2015-04-12 18:04 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
> > The documentation of combine-and-quote-strings
> > doesn't mention shell quoting at all.
>
> Here is what the on-line help says - and I quote :)...
> Here is what the Lisp manual say:...
>
> So no, it doesn't mention shell quoting (or the
> quoting of metachars as the OP puts it) but
> 1) I don't think the on-line help is clear and
> 2) the Lisp manual is clear (or more clear at least)
> save for the last sentence: the "individual
> command-line arguments"...
>
> In particular, both should make clear...
`M-x report-emacs-bug' if you think a doc improvement
is in order.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: combine-and-quote-strings
2015-04-12 10:55 ` combine-and-quote-strings Pascal J. Bourguignon
2015-04-12 16:15 ` combine-and-quote-strings Emanuel Berg
@ 2015-04-14 18:54 ` Philipp Stephani
1 sibling, 0 replies; 6+ messages in thread
From: Philipp Stephani @ 2015-04-14 18:54 UTC (permalink / raw)
To: Pascal J. Bourguignon, help-gnu-emacs
Pascal J. Bourguignon <pjb@informatimago.com> schrieb am So., 12. Apr. 2015
um 13:05 Uhr:
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> > Hi,
> >
> > the Lisp manual explains (in the section "Shell Arguments"):
> >
> > The following two functions are useful for combining a list of
> > individual command-line argument strings into a single string,
> >
> > This is about combine-and-quote-strings (and
> > split-strings-and-unquote). However, combine-and-quote-strings can't
> > really be used for that purpose because it doesn't quote many shell
> > metacharacters. The correct way to shell-quote a list of arguments is
> >
> > (mapconcat #'shell-quote-argument ARGS " ")
> >
> > Should combine-and-quote-strings be reimplemented in terms of
> > shell-quote-argument? The current definition doesn't seem to be optimal
> > for shell quoting because many inputs aren't properly quoted.
> >
> > Or is combine-and-quote-strings not intended for shell quoting at all
> > and the documentation should be adapted?
>
> The documentation ofcombine-and-quote-strings doesn't mention shell
> quoting at all.
>
>
True, but it sounds as if it could be used for shell quoting, and only
careful reading of the Elisp manual or the source code will tell otherwise.
At least I was initially confused about this. Maybe a warning could be
added to both the function documentation and the Elisp manual that these
functions are not intended for shell quoting?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: combine-and-quote-strings
2015-04-12 18:04 ` combine-and-quote-strings Drew Adams
@ 2015-04-14 19:06 ` Philipp Stephani
0 siblings, 0 replies; 6+ messages in thread
From: Philipp Stephani @ 2015-04-14 19:06 UTC (permalink / raw)
To: Drew Adams, Emanuel Berg, help-gnu-emacs
Drew Adams <drew.adams@oracle.com> schrieb am So., 12. Apr. 2015 um
20:05 Uhr:
> > > The documentation of combine-and-quote-strings
> > > doesn't mention shell quoting at all.
> >
> > Here is what the on-line help says - and I quote :)...
> > Here is what the Lisp manual say:...
> >
> > So no, it doesn't mention shell quoting (or the
> > quoting of metachars as the OP puts it) but
> > 1) I don't think the on-line help is clear and
> > 2) the Lisp manual is clear (or more clear at least)
> > save for the last sentence: the "individual
> > command-line arguments"...
> >
> > In particular, both should make clear...
>
> `M-x report-emacs-bug' if you think a doc improvement
> is in order.
>
Thanks, created bug http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20333.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-04-14 19:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.502.1428836406.904.help-gnu-emacs@gnu.org>
2015-04-12 10:55 ` combine-and-quote-strings Pascal J. Bourguignon
2015-04-12 16:15 ` combine-and-quote-strings Emanuel Berg
2015-04-12 18:04 ` combine-and-quote-strings Drew Adams
2015-04-14 19:06 ` combine-and-quote-strings Philipp Stephani
2015-04-14 18:54 ` combine-and-quote-strings Philipp Stephani
2015-04-12 10:59 combine-and-quote-strings Philipp Stephani
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).