Re: I need help with my run keeper

2025-10-31 Thread ToddAndMargo via perl6-users

On 10/30/25 4:44 AM, ToddAndMargo via perl6-users wrote:

I am missing what run does with
(not finding them in https://docs.raku.org/routine/run)


Care of search.brave.com's AI, this is what
I am finding.  I am not sure of what is accurate
and what is "AI slop" though:


    :$cwd


https://search.brave.com/search?q=raku+what+is+%3A%24cwd+&summary=1&conversation=783875ea252b2bde84a599

In Raku, :$CWD is a named argument used when creating an
IO::Path object to specify the current working directory
that the path is relative to. This value defaults to the
global variable $*CWD, which holds the current working
directory of the program. The :$CWD argument is passed
to the IO::Path.new method and is stored as the $.CWD
attribute of the resulting IO::Path object. This attribute
is read-only and is used during path resolution and
stringification operations. The :$CWD argument allows
for explicit control over the base directory for relative
paths, which is particularly useful in testing or when
working with paths in different contexts.


Sounds like if you do not put the path of your program in
and it is not in the default path, that you can set
the path with :$cmd.   Am I gettig this right?


    :$env


https://search.brave.com/search?q=raku+what+is+%3A%24env&summary=1&conversation=d7e602378b67e0046370d0

In Raku, :$env is not a standard or predefined variable. However,
the syntax :$var in Raku is used to create a named parameter
in a subroutine signature that expects a value for the named
parameter var. For example, :$env would expect a named argument
env when calling a subroutine.

If you are referring to environment variables in Raku, the
correct way to access them is through the %*ENV hash, which
contains the environment variables of the underlying operating
system.

For instance, you can retrieve an environment variable like
API_KEY using %*ENV or :$API_KEY in a signature
to bind it to a variable.

The :$env syntax might be confused with the env variable
in Rack middleware, which is a hash containing details
about the HTTP request and environment in Ruby on Rails
applications, but this is unrelated to Raku.
In Raku, environment variables are accessed via %*ENV,
and there is no built-in :$env variable.


I am completely lost.


    :$arg0   and


https://search.brave.com/search?q=raku+what+is+%3A%24arg0&summary=1&conversation=06ac2b89c0e415523f6cb7

In Raku, the :$arg0 parameter is an optional named argument
used within the run subroutine to specify the value of the
argv for the process being executed. This argument allows
you to set the name of the program as it appears in the process
list or within the program's own argument vector. It is
particularly useful when you want to control how the executed
program identifies itself, which can be important for
logging, debugging, or compatibility with programs that
rely on their own name being set in a specific way.


What is argv and why would I use this?


    :$win-verbatim-args


https://search.brave.com/search?q=raku+what+is+%3A%24win-verbatim-args&summary=1&conversation=245e089c41b17b4984d86e

In Raku, the :$win-verbatim-args parameter is a flag used with
the spawn, shell, and Proc::Async.new methods to control how
command-line arguments are quoted on Windows systems. When
set to True, it disables the automatic quoting of process
arguments according to Microsoft conventions, and instead
concatenates the arguments with a single space, allowing
the user to manually handle quoting as needed. This flag
is ignored on non-Windows platforms. It was introduced
in Rakudo version 2020.06 and is not available in older
releases. By default, :$win-verbatim-args is set to False,
which maintains the previous behavior of quoting arguments
according to Microsoft standards.


Not sure why I would what tho use this.  I do know that
Raku has had a problem in Windows with arguments with
spaces in them surrounded by quotes.   My work around
is to create a batch file and call the batch file with
what I need.


Yours in Confusion,
-T






I need help with my run keeper

2025-10-30 Thread ToddAndMargo via perl6-users

Hi All,

With Bruce's help, I have been updating my keeper
on "run"


I am missing what run does with
(not finding them in https://docs.raku.org/routine/run)

   :$cwd
   :$env
   :$arg0   and
   :$win-verbatim-args


This is what I have so far:

method new(Proc:U:
:$in = '-',
:$out = '-',
:$err = '-',
Bool :$bin = False,
Bool :$chomp = True,
Bool :$merge = False,
Str:D :$enc = 'UTF-8',
Str:D :$nl = "\n",
--> Proc:D)

sub run(
*@args ($, *@),
:$in = '-',# use `:$in`, `$:out`, and `:$err` arguments 
to redirect to
   # different file handle, thus creating a 
kind of pipe

:$out = '-',   # syntax to change these values is
   # :out($alt-handle) 


:$err = '-',
Bool :$bin = False,# $bin controls whether the streams are 
handled as
   # binary (i.e. Blob object) or text (i.e. 
Str objects).
   # If $bin is False, $enc holds the character 
encoding
   # to encode strings sent to the input stream 
and decode

   # binary data from the output and error streams.
Bool :$chomp = True,   # With $chomp set to True, newlines are 
stripped from
   # the output and err streams when reading 
with lines or get.
Bool :$merge = False,  # If $merge is set to True, the standard 
output and error

   # stream end up merged in $proc.out.
Str:D :$enc = 'UTF-8', # the type of text: UTF-8, UTF-16, etc.
Str:D :$nl = "\n", # $nl controls what your idea of a newline is
:$cwd = $*CWD,
Hash() :$env = %*ENV,
:$arg0,
:$win-verbatim-args = False
--> Proc:D)