On Tue, 04 Apr 2017 02:52:53 -0700, comdog wrote:
> I originally asked about this on Stackoverflow
> (http://stackoverflow.com/q/43199427/2766176)
> 
> This `try` catches the exception:
> 
> try die X::AdHoc;
> say "Got to the end";
> 
> The output shows that the program continues:
> 
> Got to the end
> 
> If I attempt it with `shell` and a command that doesn't exit with 0,
> the `try` doesn't catch it:
> 
> try shell('/usr/bin/false');
> say "Got to the end";
> 
> The output doesn't look like an exception:
> 
> The spawned command '/usr/bin/false' exited unsuccessfully (exit code:
> 1)
>   in block <unit> at ... line ...
> 
> What's going on that this makes it through the `try`?
> 
> --- Perl variables ---
> Perl:       Perl 6
> Executable: perl6
> Flavor:     Rakudo 2017.01
> VM:         MoarVM 2017.01
> Distro:     macosx
> Kernel:     darwin
> PERL6LIB:
> 
> --- Other Environment ---
> LANG: en_US.UTF-8
> LANGUAGE: en_US.UTF-8
> LC_ALL: en_US.UTF-8
> LESSCHARSET: utf-8
> LOCALE_I_WANT: en_US.UTF-8
> LOCAL_PATH: /usr/local/bin
> SHELL: /bin/bash
> SHLVL: 1
> TERM: vt100


Thank you for the report. However, there's no bug here.

try catches exceptions. shell() doesn't throw, but returns a Proc object.
Proc objects with non-zero exist status throw when sunk.

So in your code, the try gives a Proc object a pass, it immediately gets sunk, 
and explodes (outside of try).

You can use `try sink shell '/usr/bin/false'` to get it to explode inside of 
try. 

We also have a support channel where you can ask questions like this one: 
https://webchat.freenode.net/?channels=#perl6

Reply via email to