|
From: Ethan A M. <merritt@u.washington.edu> - 2005-11-13 22:06:34
|
On Sunday 13 November 2005 01:44 pm, Juergen Wieferink wrote:
> gnuplot> set title 'C:\'; show title
> gnuplot> show title
>
> title is "C:\\'; show title", offset at ((character units) 0, 0, 0)
>
> gnuplot>
>
> As I said: The string is implicitly ended by the end of the line,
> not by the last single quote.
Not quite right.
It *would* be ended by the trailing single quote, if there were one.
But there is no such trailing single quote in your command line
because the only candidate has been escaped by a backslash.
gnuplot> set title 'C:\'; foo' ; show title
title is "C:\\'; foo", offset at ((character units) 0, 0, 0)
The backslash character is always interpreted as an escape during input.
Single or double quotes make no difference.
I agree with Juergen that it may not be the most intuitive syntax,
but gnuplot is not the only program to behave this way.
I also agree that it might be more intuitive to have the lack of
a trailing quote be reported as an error, rather than being silently
"corrected" by adding an implicit extra character.
That still wouldn't make the original example work, but at least
you might get some hint as to what went wrong. Something like:
gnuplot> cd 'C:\'
^
Error: No trailing quote found for string constant.
>
> > In gnuplot, the \ is escape character in "this" string, but a normal
> > character in 'this' string.
>
> I would have expected this, too, two months ago. But which section
> of the docs says so? I haven't found any. If I had, I would have
> submitted a bug report, then. I say, it's not a bug, it's weird
> undocumented behaviour (which may end up being mostly the same).
> But there *is* an example of a similar syntax out there (raw
> strings). So there probably is a reason for it.
>
> Don't get me wrong: I don't promote the current syntax. Change it
> if you like. I just want to explain it.
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742
|