Program
In the prelude: every iyi program has it, with no import.
Programclass
class Program
# The arguments after the program's own name, the way every shell
# hands them over.
def self.args : Array(String)
# The directory the process is in, which is not what `PWD` says.
# `PWD` is a variable a shell keeps: cmd and PowerShell never set it,
# so on Windows every program that expanded a relative path panicked
# ("no base given and PWD is not set"), and on POSIX it is a copy that
# a program's own `Dir.cd` leaves behind. Nil when the platform has no
# answer — wasm32-wasi resolves a path against a preopened directory
# and names none — or when the directory is gone from under the
# process.
#
# 4096 bytes covers POSIX's PATH_MAX and Windows' MAX_PATH; the second
# try is for a Windows path built with `\\?\`, which reaches 32,767
# characters and up to three UTF-8 bytes each.
def self.cwd : String | Nil
# One variable, or nil. No map of everything: the asking program names
# what it wants, and a tool that dumps its whole environment into a
# structure was one `puts` away from leaking it.
def self.env(name : String) : String | Nil
end
The running program: its arguments and its environment, on demand.