Re: run "...", :out forgetting about the exit code?

2016-02-03 Thread Siavash

Nitpick: 'use strict' is the default.

On 2016-02-03 03:07:18 IRST, Peter Pentchev wrote:
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false"; say 
> $p.exitcode;'


Re: run "...", :out forgetting about the exit code?

2016-02-02 Thread Brandon Allbery
On Tue, Feb 2, 2016 at 6:37 PM, Peter Pentchev  wrote:

> So, uhm, what am I missing?  Shouldn't $p.exitcode remain 1 no matter
> whether
> I've invoked run() with or without :out?  Should I file a bug?
>

https://rt.perl.org/Ticket/Display.html?id=125757

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: run "...", :out forgetting about the exit code?

2016-02-02 Thread Peter Pentchev
On Wed, Feb 03, 2016 at 01:37:18AM +0200, Peter Pentchev wrote:
> Hi,
> 
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false"; say 
> $p.exitcode;'1
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false", 
> :out; say $p.exitcode;'
> 0
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false", 
> :out; print $p.out.slurp-rest; say $p.exitcode;'
> 0
> [roam@straylight ~]$ 
> 
> So, uhm, what am I missing?  Shouldn't $p.exitcode remain 1 no matter whether
> I've invoked run() with or without :out?  Should I file a bug?

Just for the record, my $p = Proc.new(:out); $p.spawn(...); behaves in
exactly the same way (no big surprise there, just thought I'd check).

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@freebsd.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: run "...", :out forgetting about the exit code?

2016-02-02 Thread Peter Pentchev
On Wed, Feb 03, 2016 at 01:37:18AM +0200, Peter Pentchev wrote:
> Hi,
> 
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false"; say 
> $p.exitcode;'1
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false", 
> :out; say $p.exitcode;'
> 0
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false", 
> :out; print $p.out.slurp-rest; say $p.exitcode;'
> 0
> [roam@straylight ~]$ 
> 
> So, uhm, what am I missing?  Shouldn't $p.exitcode remain 1 no matter whether
> I've invoked run() with or without :out?  Should I file a bug?
> 
> It doesn't matter whether the program actually produces any output on
> the standard output stream:
> 
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "sh", "-c", 
> "env LANG=C date; exit 3"; say $p.exitcode;'  
>  
> Wed Feb  3 01:34:50 EET 2016
> 3
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "sh", "-c", 
> "env LANG=C date; exit 3", :out; say "<<<" ~ $p.out.slurp-rest ~ ">>>"; say 
> $p.exitcode;' 
>
> << >>>
> 0
> [roam@straylight ~]$

Hm.  Okay.  I think I figured it out.  When I added a $p.out.close
call to make sure that the process has *really* exited, it threw
a X::Proc::Unsuccessful exception at me right there.  For some
reason I thought that assigning the process to a variable would
protect me from the exception.

However, I'm still a bit confused - the Proc documentation seems to
say that exitcode() will return -1, not 0, if the process has not
ended yet.  Is this the real problem here?

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@freebsd.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: run "...", :out forgetting about the exit code?

2016-02-02 Thread Peter Pentchev
On Tue, Feb 02, 2016 at 06:41:12PM -0500, Brandon Allbery wrote:
> On Tue, Feb 2, 2016 at 6:37 PM, Peter Pentchev  wrote:
> 
> > So, uhm, what am I missing?  Shouldn't $p.exitcode remain 1 no matter
> > whether
> > I've invoked run() with or without :out?  Should I file a bug?
> >
> 
> https://rt.perl.org/Ticket/Display.html?id=125757

Oof, right.  Yeah, as witnessed by my other mail, I did realize that
the process was still running.  Still, as mentioned there,
http://doc.perl6.org/type/Proc#method_exitcode says something about
-1 if the process has not exited yet; I guess that's what threw me.

Thanks, and sorry for not looking through RT!

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@freebsd.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature