Quantcast

Re: [Pharo-dev] ./pharo --help returns exit code 1 on ubuntu

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] ./pharo --help returns exit code 1 on ubuntu

Ben Coman
 
[CC vm-dev]

On Sat, May 6, 2017 at 7:04 PM, K K Subbu <[hidden email]> wrote:
On Friday 05 May 2017 02:11 PM, Andrei Chis wrote:
...
./pharo -help
unknown option: -help
Common <option>s:
  --help                 print this help message, then exit

Then `./pharo -help` returns an exit code of 1 on mac/linux while
`./pharo --help` returns a exit code of 0 on mac and 1 on linux.

It is --help on Pharo and -help on other compiles (see below). Can anyone shed light on the legacy compatibility comment in :

---- platforms/unix/vm/sqUnixMain.c ----
1421   /* legacy compatibility */            /*** XXX to be removed at some time ***/
1422

Looking just at just the file, it appears this is comment is strongly associated with the code below,
but git blame [1] indicates the comment is 7 years old, while the code below is 7 months old.  ??? 


cheers -ben
 

1423 #ifdef PharoVM
1424 # define VMOPTION(arg) "--"arg
1425 #else
1426 # define VMOPTION(arg) "-"arg
1427 #endif

It's still not clear why running the vm to print the help of the version
should exit with an error code.

Agreed. I think --help and --version should return 0. I think the 1 was to catch incorrect/unknown arguments.

If I learn the rationale behind the change, I can propose a patch to fix this.

Regards .. Subbu



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] ./pharo --help returns exit code 1 on ubuntu

K K Subbu
 
On Sunday 07 May 2017 06:35 AM, Ben Coman wrote:

>     ---- platforms/unix/vm/sqUnixMain.c ----
>     1421   /* legacy compatibility */            /*** XXX to be removed
>     at some time ***/
>     1422
>
>
> Looking just at just the file, it appears this is comment is strongly
> associated with the code below,
> but git blame [1] indicates the comment is 7 years old, while the code
> below is 7 months old.  ???

Thanks for moving this thread to vm-dev.

The latter code probably tried to get options to conform to unix
convention of using single dash for single letter options and double
dash for word options for all its applications. This convention applies
to unix apps but need not apply to virtual machines like qemu-* or
squeak*. Both these VMs use single dash for all their options.

I feel it is fine to stick to single dash for all squeak options but
have the code accept both single and double dashes as prefixes. Generate
strictly but accept liberally. All our scripts will use single dash, but
if someone types in double-dash due to habit, the VM will recover
gracefully.

Esteban? What do you think?

I can generate a patch to fix this, if there is a general consensus on
this list.

Regards .. Subbu
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] ./pharo --help returns exit code 1 on ubuntu

K K Subbu
In reply to this post by Ben Coman
 
On Friday 05 May 2017 03:01 AM, Andrei Chis wrote:
>
> On mac the error code is 0. Also when executing './pharo' or './pharo
> Pharo.image --help' or './pharo --version' the error code is 0 on both
> mac and linux.
> So it seems there is some issues with --help. Actually, it gives a usage
> warning, but still I'd expect to not return an error code.

OK, I have uploaded a patch:

https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/136

that accepts both single and double-dashes for options on unix builds.
help or version options return 0 on exit.

Regards .. Subbu
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] ./pharo --help returns exit code 1 on ubuntu

Eliot Miranda-2
 
Hi All,

    I like Subbu's fixing of the error codes.  I'm not sure the accept both -- or - need addressing.  Thoughts?

On Sun, May 7, 2017 at 2:32 AM, K K Subbu <[hidden email]> wrote:

On Friday 05 May 2017 03:01 AM, Andrei Chis wrote:

On mac the error code is 0. Also when executing './pharo' or './pharo
Pharo.image --help' or './pharo --version' the error code is 0 on both
mac and linux.
So it seems there is some issues with --help. Actually, it gives a usage
warning, but still I'd expect to not return an error code.

OK, I have uploaded a patch:

https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/136

that accepts both single and double-dashes for options on unix builds. help or version options return 0 on exit.

Regards .. Subbu



--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] ./pharo --help returns exit code 1 on ubuntu

Ben Coman
 
In the help I see this usage...
    squeak [<option>...] -- [<argument>...]

but I don't grok it enough to test if that is affected by...
   +  if (argv[0][0] == '-' && argv[0][1] == '-')
   + argv[0]++; /* skip one dash in double dash options */


Otherwise there seems no obvious harm in being permissive in handling both -- or -     

Also, maybe just bike-shedding, but
     ./pharo --help   

would then display...
   -version              print version information, then exit

instead of current... 
   --version              print version information, then exit
  
Esteban would need to advise whether this is of concern. 


btw, anyone wanting try the PR can do...
$ git remote add OpenSmalltalk https://github.com/OpenSmalltalk/opensmalltalk-vm.git # if you don't already have it
$ git fetch OpenSmalltalk pull/136/head:dd
$ git checkout dd

 
cheers -ben

On Tue, May 9, 2017 at 8:39 AM, Eliot Miranda <[hidden email]> wrote:
 
Hi All,

    I like Subbu's fixing of the error codes.  I'm not sure the accept both -- or - need addressing.  Thoughts?

On Sun, May 7, 2017 at 2:32 AM, K K Subbu <[hidden email]> wrote:

On Friday 05 May 2017 03:01 AM, Andrei Chis wrote:

On mac the error code is 0. Also when executing './pharo' or './pharo
Pharo.image --help' or './pharo --version' the error code is 0 on both
mac and linux.
So it seems there is some issues with --help. Actually, it gives a usage
warning, but still I'd expect to not return an error code.

OK, I have uploaded a patch:

https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/136

that accepts both single and double-dashes for options on unix builds. help or version options return 0 on exit.

Regards .. Subbu



--
_,,,^..^,,,_
best, Eliot


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] ./pharo --help returns exit code 1 on ubuntu

K K Subbu
 
On Tuesday 09 May 2017 09:40 PM, Ben Coman wrote:
> would then display...
>    -version              print version information, then exit
>
> instead of current...
>    --version              print version information, then exit

It is easy to change this to:

      [-]-version  .....

BTW, I just noticed that dash stripping code has to be done in
parseArgument and not in vm_parseArgument. options are being handled by
other vm-*-* code also :-(. Will post a fix soon.

Regards .. Subbu
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] ./pharo --help returns exit code 1 on ubuntu

Ben Coman
In reply to this post by Ben Coman
 
On Wed, May 10, 2017 at 12:10 AM, Ben Coman <[hidden email]> wrote:
> In the help I see this usage...
>     squeak [<option>...] -- [<argument>...]
>
> but I don't grok it enough to test if that is affected by...
>    +  if (argv[0][0] == '-' && argv[0][1] == '-')
>    + argv[0]++; /* skip one dash in double dash options */
>

To answer myself...
     squeak [<option>...] -- [<argument>...]
is handled one level up in parseArguments() before parseArgument() is called.
    sqUnixMain.c:1808:  if (!strcmp(*argv, "--")) /* escape from
option processing */
                                            break;
so it is not affected.

cheers -ben
Loading...