Difference between revisions of "Shell (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(renamed shell.programs optional argument)
m (Rewrote some descriptions of some functions)
Line 13: Line 13:
 
|{{type|string}} directory
 
|{{type|string}} directory
 
|[[shell.dir]]()
 
|[[shell.dir]]()
|Returns the directory.
+
|Returns the path to the working directory.
 
|-
 
|-
 
|
 
|
 
|[[shell.setDir]]({{type|string}} path)
 
|[[shell.setDir]]({{type|string}} path)
|Sets the directory.
+
|Sets the working directory.
 
|-
 
|-
 
|{{type|string}} path
 
|{{type|string}} path
Line 49: Line 49:
 
|{{type|table}} programs
 
|{{type|table}} programs
 
|[[shell.programs]]([<nowiki/>{{type|boolean}} showHidden])
 
|[[shell.programs]]([<nowiki/>{{type|boolean}} showHidden])
|Returns a {{type|table}} of programs.
+
|Returns a table of files in the current directory and in rom/programs.
 
|-
 
|-
 
|{{type|boolean}} success
 
|{{type|boolean}} success
 
|[[shell.run]]({{type|string}} command [, {{type|string}} args1, {{type|string}} args2, ...])
 
|[[shell.run]]({{type|string}} command [, {{type|string}} args1, {{type|string}} args2, ...])
 
|Runs a program.
 
|Runs a program.
 +
 
|-
 
|-
 
|{{type|string}} path
 
|{{type|string}} path

Revision as of 19:44, 4 April 2014

The shell API allows you to interface with the shell.

API

Returns Method name Description
shell.exit() Exits the current shell.
string directory shell.dir() Returns the path to the working directory.
shell.setDir(string path) Sets the working directory.
string path shell.path() Returns the path.
shell.setPath(string path) Sets the path.
string path shell.resolve(string localpath) Resolves a local path to an absolute path.
string path shell.resolveProgram(string name) Resolves the absolute path to the program whose name you provided.
table aliases shell.aliases() Returns aliases.
shell.setAlias(string alias, string program) Sets an alias.
shell.clearAlias(string alias) Clears an alias.
table programs shell.programs([boolean showHidden]) Returns a table of files in the current directory and in rom/programs.
boolean success shell.run(string command [, string args1, string args2, ...]) Runs a program.
string path shell.getRunningProgram() Returns the absolute path to the currently-executing program.
number newTabID shell.openTab(string command [, string args1, string args2, ...]) Runs a program in another multishell tab. Requires version 1.6 or newer and an advanced system.
shell.switchTab(number tabID) Switches the multishell tab to tab with the given ID. Requires version 1.6 or newer and an advanced system.

Note that shell.run and shell.openTab concatenate any arguments they are given (with single space separator characters) before parsing the command, and as of ComputerCraft version 1.45, now also support a single string containing all parameters.