./pharo --help returns exit code 1 on ubuntu

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

./pharo --help returns exit code 1 on ubuntu

Andrei Chis
Hi,

In an ubuntu installation with the latest vm and Pharo 6 image when executing `./pharo --help` I get an error code of 1.

wget -O- get.pharo.org/vmLatest60 | bash
wget -O- get.pharo.org/60 | bash
./pharo --help
echo $?   --> returns 1

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.

Usage: Pharo.app/Contents/MacOS/Pharo [<option>...] [<imageName> [<argument>...]]
      Pharo.app/Contents/MacOS/Pharo [<option>...] -- [<argument>...]

Cheers,
Andrei 
Reply | Threaded
Open this post in threaded view
|

Re: ./pharo --help returns exit code 1 on ubuntu

Andrei Chis
Any thoughts or places where I can look? This problem is still in the latest vm.

Cheers,
Andrei

On Thu, Mar 30, 2017 at 9:37 AM, Andrei Chis <[hidden email]> wrote:
Hi,

In an ubuntu installation with the latest vm and Pharo 6 image when executing `./pharo --help` I get an error code of 1.

wget -O- get.pharo.org/vmLatest60 | bash
wget -O- get.pharo.org/60 | bash
./pharo --help
echo $?   --> returns 1

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.

Usage: Pharo.app/Contents/MacOS/Pharo [<option>...] [<imageName> [<argument>...]]
      Pharo.app/Contents/MacOS/Pharo [<option>...] -- [<argument>...]

Cheers,
Andrei 

Reply | Threaded
Open this post in threaded view
|

Re: ./pharo --help returns exit code 1 on ubuntu

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

> Any thoughts or places where I can look? This problem is still in the
> latest vm.
>
> Cheers,
> Andrei
>
> On Thu, Mar 30, 2017 at 9:37 AM, Andrei Chis <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi,
>
>     In an ubuntu installation with the latest vm and Pharo 6 image when
>     executing `./pharo --help` I get an error code of 1.
>...
>     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.

That is strange. The source code returns 1 for both unix and Mac:

-----platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c ----
   if      (!strcmp(argv[0], "-help"))           {
         usage();
         return 1; }
-----platform/unix/vm/sqUnixMain.c
if      (!strcmp(argv[0], VMOPTION("help"))) { usage(); return 1; }
-------

BTW, the option is "-help" with a single dash. Two dashes will print the
same because the option is not recognized. You may as well type
"--hellllp" ;-).

Regards .. Subbu

Reply | Threaded
Open this post in threaded view
|

Re: ./pharo --help returns exit code 1 on ubuntu

Andrei Chis


On Fri, May 5, 2017 at 10:13 AM, K K Subbu <[hidden email]> wrote:
On Friday 05 May 2017 03:01 AM, Andrei Chis wrote:
Any thoughts or places where I can look? This problem is still in the
latest vm.

Cheers,
Andrei

On Thu, Mar 30, 2017 at 9:37 AM, Andrei Chis <[hidden email]
<mailto:[hidden email]>> wrote:

    Hi,

    In an ubuntu installation with the latest vm and Pharo 6 image when
    executing `./pharo --help` I get an error code of 1.
...
    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.

That is strange. The source code returns 1 for both unix and Mac:

-----platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c ----
  if      (!strcmp(argv[0], "-help"))           {
        usage();
        return 1; }
-----platform/unix/vm/sqUnixMain.c
if      (!strcmp(argv[0], VMOPTION("help")))            { usage();              return 1; }
-------

BTW, the option is "-help" with a single dash. Two dashes will print the same because the option is not recognized. You may as well type "--hellllp" ;-).

Thanks for the info!
It's actually a bit stranger. The option should be specified using '--'

./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.

I think this behaviour comes from [1] and [2]:

----platforms/unix/vm/sqUnixMain.c----
if (!strcmp(argv[0], VMOPTION("help"))) { usage(); return 1; }


----platforms/iOS/vm/OSX/sqSqueakOSXApplication.m----
if ([argData isEqualToString: VMOPTIONOBJ("help")]) { 
  [self usage]; 
  exit(0); 
  return 1; }

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

Cheers,
Andrei

 

Regards .. Subbu


Reply | Threaded
Open this post in threaded view
|

Re: ./pharo --help returns exit code 1 on ubuntu

K K Subbu
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

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