[REBOL] Re: Core 2.6 - Last minute requests - take your chance!
From: holger:rebol at: 7-Apr-2002 7:16
On Sun, Apr 07, 2002 at 07:55:51AM -0500, Joel Neely wrote:
> 1) Fixing inconsistencies/bugs in parsing of strings containing
> quotation marks, as in:
Yes, a known issue.
> 1) correcting the documentation to explain what PARSE
> is actually intended to do, and
>
> 2) adding a new refinement, such as /RAW, which explicitly
> means "do not attach special behavior to *ANY* characters
> in the parsed string, but leave that up to the PARSE
> rules written by the programmer" and -- of course --
> "retain all characters in the parsed string".
Yes, we will have to do one of those things... I don't know if this will make
it into 2.6 though.
> 2) Fixing the *VERY* troubling mangling of arguments from
> the command line:
>
> rebol this is "a test" of arguments
>
> >> system/script/args
> == "is a test of arguments"
This is intentional behavior. system/script/args contains a concatenation of
all arguments. Note that in your example "this" is not considered an argument,
but the name of the script, so it does not appear in the string. Splitting
arguments up in the first place, and removing the quotes, is done either by the
operating system or by the runtime system (c.lib etc.), depending on the
platform you are running on, not by our code, and there is no portable way of
avoiding that. Some operating systems also perform a much more aggressive
preprocessing such as globbing and backtick evaluation that we cannot disable
or bypass.
To get the individual arguments as a block of strings use system/options/args
instead of system/script/args. Note however, that even system/options/args does
not contain the first item on the command line ("this" in your example),
because it is considered the name of a script to start. To avoid this, and to
also avoid arguments such as "-c" getting interpreted as command line switches,
use "--" at the beginning of the command line (consistent with Unix commands).
Note that even with system/options/args quotes get removed in convention with
your operating system, so in your example system/options/args contains
["is" "a test" "of" "arguments"]
without the extra quotes around "a test". This is unavoidable, because by
the time we get control of the arguments the quotes have already been
removed.
> Note that
>
> >> system/options/args
> == ["is" "a test" "of" "arguments"]
>
> appears to be related to the first issue in this email. If
> this is the reason that PARSE behaves as described in the
> first issue, then this seems like a case of the tail wagging
> the dog.
No, quote removal in parse has nothing to do with quote removal
in command line args. Quote removal in parse is a result of /all
not being aggressive enough in changing the set of delimiters.
Quote removal in arguments is done by the operating system.
--
Holger Kruse
[kruse--nordicglobal--com]