<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ocr.michiyo.me/w/index.php?action=history&amp;feed=atom&amp;title=API%2Fshell</id>
	<title>API/shell - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ocr.michiyo.me/w/index.php?action=history&amp;feed=atom&amp;title=API%2Fshell"/>
	<link rel="alternate" type="text/html" href="https://ocr.michiyo.me/w/index.php?title=API/shell&amp;action=history"/>
	<updated>2026-08-24T13:29:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://ocr.michiyo.me/w/index.php?title=API/shell&amp;diff=1048&amp;oldid=prev</id>
		<title>imported&gt;OCDoc Import: Imported from legacy OpenComputers documentation at ocdoc.cil.li</title>
		<link rel="alternate" type="text/html" href="https://ocr.michiyo.me/w/index.php?title=API/shell&amp;diff=1048&amp;oldid=prev"/>
		<updated>2026-08-24T08:08:27Z</updated>

		<summary type="html">&lt;p&gt;Imported from legacy OpenComputers documentation at ocdoc.cil.li&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Shell API =&lt;br /&gt;
&lt;br /&gt;
This API provides shell related functionality, such as the current working directory, program search path and aliases for the shell.&lt;br /&gt;
&lt;br /&gt;
* `shell.getAlias(alias: string): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Gets the value of a specified alias, if any. If there is no such alias returns `nil`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `shell.setAlias(alias: string, value: string or nil)`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Defines a new alias or updates an existing one. Pass `nil` as the value to remove an alias. Note that aliases are not limited to program names, you can include parameters as well. For example, `view` is a default alias for `edit -r`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `shell.aliases(): function`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Returns an iterator over all known aliases.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `shell.getWorkingDirectory(): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Gets the path to the current working directory. This is an alias for `os.getenv(&amp;quot;PWD&amp;quot;)`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `shell.setWorkingDirectory(dir: string)`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Sets the current working directory. This is a checked version of `os.setenv(&amp;quot;PWD&amp;quot;, dir)`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `shell.getPath(): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Gets the search path used by `shell.resolve`. This can contain multiple paths, separated by colons (`:`).  &lt;br /&gt;
This is an alias for `os.getenv(&amp;quot;PATH&amp;quot;)`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `shell.setPath(value: string)`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Sets the search path. Note that this will replace the previous search paths. To add a new path to the search paths, do this:  &lt;br /&gt;
`shell.setPath(shell.getPath() .. &amp;quot;:/some/path&amp;quot;)`  &lt;br /&gt;
This is an alias for `os.setenv(&amp;quot;PATH&amp;quot;, value)`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `shell.resolve(path: string[, ext: string]): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Tries to &amp;quot;resolve&amp;quot; a path, optionally also checking for files with the specified extension, in which case `path` would only contain the &amp;#039;&amp;#039;name&amp;#039;&amp;#039;. This first searches the working directory, then all entries in the search path (see `getPath`/`setPath`).  &lt;br /&gt;
If no file with the exact specified name exists and an extension is provided, it will also check for a file with that name plus the specified extension, i.e. for `path .. &amp;quot;.&amp;quot; .. ext`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `shell.execute(command: string, env: table[, ...]): boolean ...`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Runs the specified command. This runs the default shell (see `os.getenv(&amp;quot;SHELL&amp;quot;)`) and passes the command to it. `env` is the environment table to use for the shell, and thus for the called program, in case you wish to sandbox it or avoid it cluttering the caller&amp;#039;s namespace. Additional arguments are passed directly to the first program started based on the command, so you can pass non-string values to programs.  &lt;br /&gt;
Returns values similar to `pcall` and `coroutine.resume`: the first returned value is a boolean indicating success or error. In case of errors, the second returned value is a detailed error message. Otherwise the remaining returned values are the values that were returned by the specified program when it terminated.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `shell.parse(...): table, table`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Utility methods intended for programs to parse their arguments. Will return two tables, the first one containing any &amp;quot;normal&amp;quot; parameters, the second containing &amp;quot;options&amp;quot;. Options are indicated by a leading `-`, and all options must only be a single character, since multiple characters following a single `-` will be interpreted as multiple options. Options specified with 2 dashes are not split and can have multiple letters. Also, 2-dash options can be given values by using an equal sign. The following examples all assume the script `program` parses the options using `local args, ops = shell.parse(...)`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;`program`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `args` is `{}`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `ops` is `{}`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;`program -abC -d arg1 arg2`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `args` is `{&amp;quot;arg1&amp;quot;, &amp;quot;arg2&amp;quot;}`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `ops` is `{a=true,b=true,C=true,d=true}`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;`program -abC --dog arg1 arg2`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `args` is `{&amp;quot;arg1&amp;quot;, &amp;quot;arg2&amp;quot;}`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `ops` is `{a=true,b=true,C=true,dog=true}`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;`program -abC --dog=foo arg1 arg2`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `args` is `{&amp;quot;arg1&amp;quot;, &amp;quot;arg2&amp;quot;}`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `ops` is `{a=true,b=true,C=true,dog=&amp;quot;foo&amp;quot;}`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;On this next example, notice the single dash before `dog`, this causes all of the token to be parsed as single chars.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;`program -abC -dog=foo arg1 arg2`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `args` is `{&amp;quot;arg1&amp;quot;, &amp;quot;arg2&amp;quot;}`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;# `ops` is `{a=true,b=true,C=true,d=true,g=true,[&amp;quot;=&amp;quot;]=true,f=true,o=true}`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Contents ==&lt;br /&gt;
&lt;br /&gt;
{{:API/contents}}&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>imported&gt;OCDoc Import</name></author>
	</entry>
</feed>