On 12/6/22 07:31, ToddAndMargo via perl6-users wrote: > On 12/6/22 01:44, ToddAndMargo via perl6-users wrote: >> Hi All, >> >> Windows Pro Chromebook Edition 22H2 (W11) >> raku -v Welcome to RakudoΓäó v2022.07. >> >> When ever I run the following, it opens >> a Notepad with the text of the calling >> raku program. >> >> raku -e "use lib '.'; use NativeWinUtils :RunCmd; say RunCmd(Q[ls]);" >> >> This is RunCmd >> >> sub RunCmd( Str $CommandStr, Bool $EchoOff = False ) returns Str is >> export( :RunCmd ) { >> my $PathIAm = $?FILE; >> my Str $BatFile = $PathIAm ~ ".bat"; >> # print "$BatFile\n"; >> my Str $RtnStr; >> my Str $CmdStr = ""; >> >> if $EchoOff { $CmdStr = Q[@echo off] ~ "\n"; } >> $CmdStr = $CmdStr ~ $CommandStr ~ "\n"; >> # print "$CmdStr"; >> >> spurt( $BatFile, $CmdStr ); >> $RtnStr = qqx { $BatFile }; >> # print "$RtnStr\n"; >> } >> >> >> It is the qqx command (it runs the created .bat file) >> that opens the notepad. >> >> The .bat file, which I leave on the disk, >> runs fine manually. >> >> And I did this to myself. I had a pop up that >> asked me what to do with something and I must >> have clicked on it by accident. >> >> -T >> > > > Its a bug in Raku: > > > > qqx tries to run the module, not the sub inside the module: > > Windows 10 Pro 21H2 > Windows 11 Pro 22H2 > > https://rakudo.org/dl/rakudo/rakudo-moar-2022.07-01-win-x86_64-msvc.msi > > > When you run this sub inside your program, there is no issue. > > If you put the sub into a module, then qqx tries to > run the module itself, not the batch file this sub > creates: > > > <RunCmdModule.pm6> > # unit module RunCmdModule; > # RunCmdModule.pm6 > > > sub RunCmd( Str $CommandStr, Bool $EchoOff = False ) returns Str is > export( :RunCmd ) { > my $PathIAm = $?FILE; > my Str $BatFile = $PathIAm ~ ".bat"; > # print "$BatFile\n"; > my Str $RtnStr; > my Str $CmdStr = ""; > > if $EchoOff { $CmdStr = Q[@echo off] ~ "\n"; } > $CmdStr = $CmdStr ~ $CommandStr ~ "\n"; > # print "$CmdStr"; > > spurt( $BatFile, $CmdStr ); > $RtnStr = qqx { $BatFile }; > # print "$RtnStr\n"; > } > </RunCmdModule.pm6> > > > Test one liner (run in the same directory as the module): > raku -e "use lib '.'; use RunCmdModule :RunCmd; say RunCmd(Q[ls]); > > Result: Windwos tries to run a .pm6 file > https://imgur.com/q7NzxIil.png > Just opened: qqx tries to run the module, not the sub inside the module https://github.com/rakudo/rakudo/issues/5120Thread Previous | Thread Next