[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] command line arguments use single dash prefix but also accept doubledash (#136)

Eliot Miranda eliot.miranda at gmail.com
Sun May 7 16:21:16 UTC 2017


IIABDFI
Esteban rewrote the code that use -- for Pharo, preserving - for Squeak.  What's the problem??

_,,,^..^,,,_ (phone)

> On May 7, 2017, at 8:50 AM, Ben Coman <notifications at github.com> wrote:
> 
> @bencoman requested changes on this pull request.
> 
> Can we have some discussion on [vm-dev] about the flexibility of Squeakers to use double-hyphen options as default?
> 
> In platforms/unix/vm/sqUnixMain.c:
> 
> > @@ -1467,7 +1464,8 @@ static int vm_parseArgument(int argc, char **argv)
>  
>    /* vm arguments */
>  
> -  if      (!strcmp(argv[0], VMOPTION("help")))		{ usage();		return 1; }
> +  if      (!strcmp(argv[0], VMOPTION("help")))		{ usage(0);         /*NOTREACHED*/}
> Would it be better to shift the exit() out of usage(), so that real code affection execution flow is used here rather than a comment. i.e. here... { usage(); exit(0) } ??
> 
> In platforms/unix/vm/sqUnixMain.c:
> 
> > @@ -1721,7 +1719,7 @@ static void usage(void)
>    printf("\nAvailable drivers:\n");
>    for (m= modules;  m->next;  m= m->next)
>      printf("  %s\n", m->name);
> -  exit(1);
> +  exit(exitValue);
> Refactor the exit() out to the caller ??
> 
> In platforms/unix/vm/sqUnixMain.c:
> 
> > @@ -1819,7 +1817,8 @@ static void parseArguments(int argc, char **argv)
>        if (n == 0)			/* option not recognised */
>  	{
>  	  fprintf(stderr, "unknown option: %s\n", argv[0]);
> -	  usage();
> +	  usage(1);
> +	  /*NOTREACHED*/
> Same as above, refactor exit out of usage() ? i.e. here...
> usage();
> exit(1)
> 
> In platforms/unix/vm/sqUnixMain.c:
> 
> >  {
>    struct SqModule *m= 0;
>    printf("Usage: %s [<option>...] [<imageName> [<argument>...]]\n", argVec[0]);
>    printf("       %s [<option>...] -- [<argument>...]\n", argVec[0]);
> +  printf("options begin with single -, but -- prefix is silently accepted\n");
> The problem is that single-hyphen default is then what is advised by --help. Why isn't it preferable to conform to Unix conventions [1] "The GNU double-hyphen option leader was chosen so that traditional single-letter options and GNU-style keyword options could be unambiguously mixed on the same command line. "
> [1] http://www.catb.org/~esr/writings/taoup/html/ch10s05.html
> 
> The single-hyphen could be silently accepted for backward compatibility. Maybe better would be a deprecated message, but perhaps that could adversely affect existing scripts(?).
> 
> How do Squeakers feel about that?
> 
>> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub, or mute the thread.
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20170507/91b3f3d1/attachment.html>


More information about the Vm-dev mailing list