Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Raku opens a notepad when executing a .bat

0 views
Skip to first unread message

ToddAndMargo via perl6-users

unread,
Dec 6, 2022, 5:00:09 AM12/6/22
to perl6-users
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

ToddAndMargo via perl6-users

unread,
Dec 6, 2022, 6:45:09 AM12/6/22
to perl6...@perl.org
On 12/6/22 03:13, ToddAndMargo via perl6-users wrote:
> On 12/6/22 02:40, Ralph Mellor wrote:
>> Please confirm that:
>>
>> * Entering `ls` at the command line prompt does what it says
>>    on the tin, it does not open notepad.
>>
>> * A Raku program that consists of the single line `qqx 'ls'` does
>>    what it says on the tin, and does not open notepad.
>>
>> If those are true, then this code:
>>
>> ```
>> use lib '.'; use NativeWinUtils :RunCmd; say RunCmd(Q[ls]);
>> ```
>> is NOT running the code you showed starting `sub RunCmd`.
>>
>> --
>> raiph
> >raku -e "use lib '.'; use NativeWinUtils :RunCmd; say RunCmd(Q[echo
> 12345]);"
>
> >raku -e "use lib '.'; use NativeWinUtils :RunCmd; say RunCmd(Q[where
> raku]);"
>
> >raku -e "use lib '.'; use NativeWinUtils :RunCmd; say RunCmd(Q[raku
> -v], True);"
>
> Anything opens notepad with the source code to
> NativeWinUtils.pm6.
>
> What in the world did I do???


I think you missed the part about the bat
file working fine.

This is the bat file created by Q[ls]

type "K:\Windows\NtUtil\NativeWinUtils.pm6 (NativeWinUtils).bat"
ls


and when run from teh command line

"K:\Windows\NtUtil\NativeWinUtils.pm6 (NativeWinUtils).bat"

K:\Windows\NtUtil>ls

K:\Windows\NtUtil>echo dir
dir

K:\Windows\NtUtil>dir
Volume in drive K is Fedora, 4.16.5
Volume Serial Number is 67EC-FE92

Directory of K:\Windows\NtUtil

12/06/2022 03:27 AM <DIR> .
11/15/2022 09:35 AM <DIR> ..
08/25/2016 12:38 PM <DIR> Aervoe
08/25/2016 12:38 PM <DIR> AIT
12/14/2018 11:18 AM <DIR> Alpen.Sierra.Roasting
08/19/2017 06:11 PM <DIR> Alpine.Fastener.Hardware
12/31/2006 02:27 PM 2,863 Backup-ExtHD.bat
03/11/2007 07:02 PM 3,311 Backup-ExtHD2.bat

This is obviously not a raku issue, but a Windows issue.

ToddAndMargo via perl6-users

unread,
Dec 6, 2022, 6:45:09 AM12/6/22
to perl6...@perl.org
I just tried this on Windows 10 and this is where
I got suckered into notepad:

https://imgur.com/jEHhAlpl.png


ToddAndMargo via perl6-users

unread,
Dec 6, 2022, 9:00:12 AM12/6/22
to perl6...@perl.org
On 12/6/22 03:31, ToddAndMargo via perl6-users wrote:
> This is obviously not a raku issue, but a Windows issue.

I think I misspoke. I do believe qqx is trying
to run the sub from the module.

I will put together a few tests in a couple of
days to see if I can get it to repeat, then I
will tag it as a bug

ToddAndMargo via perl6-users

unread,
Dec 6, 2022, 10:45:09 AM12/6/22
to perl6...@perl.org
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




--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ToddAndMargo via perl6-users

unread,
Dec 6, 2022, 11:17:14 AM12/6/22
to perl6...@perl.org
Just opened:

qqx tries to run the module, not the sub inside the module
https://github.com/rakudo/rakudo/issues/5120

0 new messages