shell_cmd 0.2.2 shell_cmd: ^0.2.2 copied to clipboard
A library for running programs either explicitly or in shell
A library for running programs either explicitly or in an OS-specific shell
Features #
-
Instance method
parse
to break single string into an executable and its arguments. This was done due to the current state ofsplitShell
of the packageio
is not usable, as it is hardwired to POSIX conventions: escape character is always\
, line comment start is always#
, strings likeab|cd
andab>cd
are not split in three, etc. The flagrunInShell
indicates whether the command should be run in shell (having special characters) or not. -
Instance wrapper methods
run
andrunSync
(forProcess.run
andProcess.runSync
respectively) accept the first parameter as the full command in a single string. The package guarantees that when the parameterrunInShell
is true, the excution result will be exactly the same as if that command would be run as a script. If this parameter is omitted, the memberrunInShell
will be used. The shell is not required to besh
(POSIX) orcmd.exe
(Windows). First of all, the API tries to get that from the environment variableSHELL
(POSIX) orCOMSPEC
(Windows), then falls back onto the ones noted before. It is possible to set the shell to anything else explicitly viasetShell
. -
Methods
which
andwhichSync
to expand filename into full path if found in PATH. Under Windows, it will also try to append every extension fromPATHEXT
.
Usage #
See under the Example
tab. All sample code files are under the sub-directory example
.