Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get Perl 6's run to work on Windows?

Tags:

windows

raku

I'm playing with run on Windows. Trying it with dir doesn't work but maybe I'm missing something:

put '-' x 70;
my $p1 = run 'dir', :out;
put "exit code: {$p1.exitcode}";
put $p1.out.slurp(:close);

put '-' x 70;
my $p2 = Proc.new: :out;
put "exit code: {$p2.exitcode}";
$p2.spawn: 'dir';
$p2.out.slurp(:close).say;

The output is just the rule and exit code lines:

----------------------------------------------------------------------       
exit code: 1                                                                 

----------------------------------------------------------------------       
exit code: 1                                                                 

The dir works fine with shell but that's a different way of doing things. I could do this but that's going through the shell which run wants to avoid:

my $p1 = run 'cmd.exe', '/C', 'dir', :out;
like image 616
brian d foy Avatar asked Apr 25 '18 22:04

brian d foy


1 Answers

This is expected behavour given that dir is a shell command, not an executable.

If you hit ⊞ Win+R to open the run dialog and enter dir, it will fail for the same reason (unless you happen to have an unrelated executable dir.exe somewhere in your path).

like image 192
Christoph Avatar answered Nov 09 '22 23:11

Christoph