Andy Lester writes:

> As much as I like the non-quotedness of the -- or --testargs idea, I
> really think it needs to be --testargs='--foo --bar'.

If we have just -- then its straightforward what to do with the
arguments.  After everything up to and including -- has been shifted off
@ARGV, then you can just do:

  my @test_args = @ARGV;

and if $test_file is the test being run you can then do the moral
equivalent of:

  system $test_file, @test_args;

But with --testargs you read in a single string so you get something
like:

  $test_args = '--foo --bar';

And suppose we're trying to run $test_file.  Obviously this is wrong:

  system $test_file, $test_args;

For the above arguments you'd want to do:

  system $test_file, split / /, $test_args;

But what if one of the arguments needs to have a space in it.  With --
you can do:

  % runtests whatever -- --foo "kapow blam"

How do you write that with --testargs?  Perhaps:

  % runtests whatever --testargs='--foo "kapow blam"'

Hmmm, but now this is wrong:

  system $test_file, split / /, $test_args;

We need to only split on the unquoted whitespace, and we need to remove
the quotes from the outside of what will then be the second argument.

Obviously it's possible to do that.  But it's hard to get it right, and
to meet users' expectations.

In particular, different OSes have different quoting rules.  With --
it's still the local shell doing the quoting, so the user obviously just
uses their normal quoting rules.  With --testargs, runtests would be
doing the parsing.  Should it emulate the local OS's rules (but then
behaving differently on each platform), or should it pick one set of
rules and implement them everywhere (but then imposing, say, Unix-style
quoting on Windows users)?

The convention of using '--' to mean 'that's the end of my own
arguments' neatly avoids all of these issues.

Smylers

Reply via email to