ShellCmd class

Static API to split an arbitrary command and to execute that

Constructors

ShellCmd([String? command])
Default constructor

Properties

args List<String>
Actual arguments
final
hashCode int
The hash code for this object.
no setterinherited
program String
Program (executable) path
getter/setter pair
runInShell bool
When true, running the command in shell is recommended
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
text String
Command text
getter/setter pair

Methods

clear() → void
Resets instance properties
copyFrom(ShellCmd that, {String? text, String? program, List<String>? args}) → void
Copy constructor
init([String? newText, String? newProgram, List<String>? newArgs]) → void
Copy constructor
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse([String? text]) → void
Split an arbitrary command into separate unquoted tokens, move the first one to program and set text.
run({String? command, String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool? runInShell, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding}) Future<ProcessResult>
Split an arbitrary command and execute that in the non-blocking mode.
runSync({String? command, String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool? runInShell, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding}) ProcessResult
Split an arbitrary command and execute that in the blocking mode.
setText([String? newText]) String
Set text to the argument newText. If the latter is null, then merge program and args to text.
toString() String
Serializer
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

defaultShellCommand String
Default shell executable and its args as a single string (text)
final
dirListSeparator String
Separator used to split directories in the PATH variable (OS-specific)
final
escapeChar String
Const: char for the character escaping (OS-specific)
final
escapeCharCode int
Const: char code for the character escaping (OS-specific)
final
escapeCharEscaped String
Const: char for the character escaping (OS-specific)
final
isWindows bool
Const: current OS is Windows
final
lineBreak String
Const: Line separator (OS-specific)
final
lineCommentStartChar String
Const: char for the line comment start (OS-specific)
final
lineCommentStartCharCode int
Const: char code for the line comment start (OS-specific)
final
shell ShellCmd
Current shell
getter/setter pair
shellEnvKey String
Const: environment variable name to retrieve OS default shell
final
spaceCharEscaped String
Const: plain space char escaped (OS-specific)
final
tabChar String
Const: tab char
final
tabCharEscaped String
Const: plain space char escaped (OS-specific)
final

Static Methods

createTempDir() Future<Directory>
Under POSIX-compliant OS, does nothing and returns null.
Under Windows, creates a temporary directory (non-blocking) and returns that
createTempDirSync() Directory
Under POSIX-compliant OS, does nothing and returns null.
Under Windows, creates a temporary directory (blocking) and returns that
createTempScript(String? command) Future<String>
Under POSIX-compliant OS, does nothing and returns an empty string.
Under Windows, creates a temporary folder (non-blocking) and writes command to an output file.
This file should be executed and deleted with the containing folder
createTempScriptSync(String? command) String
Under POSIX-compliant OS, does nothing and returns an empty string.
Under Windows, creates a temporary folder (blocking) and writes command to an output file.
This file should be executed and deleted with the containing folder
deleteTempScript(String? scriptPath) Future<void>
Deletes file created by createTempScript as well as containing folder (non-blocking)
deleteTempScriptSync(String? scriptPath) → void
Deletes file created by createTempScript as well as containing folder (blocking)
escape(String arg) String
Convenience method to merge program and arguments into a single string
fromParsed(String program, List<String> args, {String? text}) ShellCmd
Constructor from parsed command (a program path and a separate list of args)
getEmptyResult(int exitCode, [String? error]) ProcessResult
Get empty process result in case of no need to run command
resetShell() ShellCmd
Copy from the default shell
setShell({String? command, bool force = false}) ShellCmd
Set default OS-specific shell
which(String fileName, {bool alwaysFound = false}) Future<String>
Find full path by checking fileName in every directory of the PATH (non-blocking).
Returns fileName if alwaysFound is true, or an empty string otherwise.
whichSync(String fileName) String
Find full path by checking fileName in every directory of the PATH (blocking).
If fileName contains directory, returns canonicalized path (lowered in Windows).
If fileName is found in one of the PATH directories, returns full path as a join between that directory and fileName. Otherwise, returns an empty string.

Constants

spaceChar → const String
Const: plain space char
tempScriptName → const String
Const: temporary script name as well as temporary dir prefix