class Sys
no package
This class provides access to various base functions of system platforms.
Look in the sys
package for more system APIs.
Static methods
staticargs():Array<String>
Returns all the arguments that were passed in the command line. This does not include the interpreter or the name of the program file.
(java)(eval) On Windows, non-ASCII Unicode arguments will not work correctly.
(cs) Non-ASCII Unicode arguments will not work correctly.
staticcommand(cmd:String, ?args:Array<String>):Int
Runs the given command. The command output will be printed to the same output as the current process.
The current process will block until the command terminates.
The return value is the exit code of the command (usually 0
indicates no error).
Command arguments can be passed in two ways:
-
Using
args
to pass command arguments. Each argument will be automatically quoted and shell meta-characters will be escaped if needed.cmd
should be an executable name that can be located in thePATH
environment variable, or a full path to an executable. -
When
args
is not given or isnull
, command arguments can be appended tocmd
. No automatic quoting/escaping will be performed.cmd
should be formatted exactly as it would be when typed at the command line. It can run executables, as well as shell commands that are not executables (e.g. on Windows:dir
,cd
,echo
etc).
Use the sys.io.Process
API for more complex tasks, such as background processes, or providing input to the command.
staticexit(code:Int):Void
Exits the current process with the given exit code.
(macro)(eval) Being invoked in a macro or eval context (e.g. with -x
or --run
) immediately terminates
the compilation process, which also prevents the execution of any --next
sections of compilation arguments.
staticgetCwd():String
Gets the current working directory (usually the one in which the program was started).
staticgetEnv(s:String):String
Returns the value of the given environment variable, or null
if it
doesn't exist.
staticprintln(v:Dynamic):Void
Prints any value to the standard output, followed by a newline. On Windows, this function outputs a CRLF newline. LF newlines are printed on all other platforms.
staticsetCwd(s:String):Void
Changes the current working directory.
(java) This functionality is not available on Java; calling this function will throw.
staticsystemName():String
Returns the type of the current system. Possible values are:
- "Windows"
- "Linux"
- "BSD"
- "Mac"