mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge remote-tracking branch 'upstream/master-MC1.7.10' into master-MC1.8.9
This commit is contained in:
commit
dd15d6c7fb
@ -1,22 +1,30 @@
|
|||||||
local args = {...}
|
local shell = require("shell")
|
||||||
if args[1] then
|
local args, ops = shell.parse(...)
|
||||||
|
local hostname = args[1]
|
||||||
|
|
||||||
|
if hostname then
|
||||||
local file, reason = io.open("/etc/hostname", "w")
|
local file, reason = io.open("/etc/hostname", "w")
|
||||||
if not file then
|
if not file then
|
||||||
io.stderr:write(reason .. "\n")
|
io.stderr:write("failed to open for writing: ", reason, "\n")
|
||||||
return 1
|
return 1
|
||||||
else
|
|
||||||
file:write(args[1])
|
|
||||||
file:close()
|
|
||||||
os.setenv("HOSTNAME", args[1])
|
|
||||||
os.setenv("PS1", "$HOSTNAME:$PWD# ")
|
|
||||||
end
|
end
|
||||||
|
file:write(hostname)
|
||||||
|
file:close()
|
||||||
|
ops.update = true
|
||||||
else
|
else
|
||||||
local file = io.open("/etc/hostname")
|
local file = io.open("/etc/hostname")
|
||||||
if file then
|
if file then
|
||||||
io.write(file:read("*l"), "\n")
|
hostname = file:read("*l")
|
||||||
file:close()
|
file:close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if ops.update then
|
||||||
|
os.setenv("HOSTNAME_SEPARATOR", hostname and #hostname > 0 and ":" or "")
|
||||||
|
os.setenv("HOSTNAME", hostname)
|
||||||
|
elseif hostname then
|
||||||
|
print(hostname)
|
||||||
else
|
else
|
||||||
io.stderr:write("Hostname not set\n")
|
io.stderr:write("Hostname not set\n")
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
@ -24,32 +24,23 @@ function os.getenv(varname)
|
|||||||
local env = env()
|
local env = env()
|
||||||
if not varname then
|
if not varname then
|
||||||
return env
|
return env
|
||||||
|
elseif varname == '#' then
|
||||||
|
return #env
|
||||||
end
|
end
|
||||||
return env[varname]
|
return env[varname]
|
||||||
end
|
end
|
||||||
|
|
||||||
function os.setenv(varname, value)
|
function os.setenv(varname, value)
|
||||||
checkArg(1, varname, "string", "number")
|
checkArg(1, varname, "string", "number")
|
||||||
if value == nil then
|
if value ~= nil then
|
||||||
env()[varname] = nil
|
value = tostring(value)
|
||||||
else
|
|
||||||
local success, val = pcall(tostring, value)
|
|
||||||
if success then
|
|
||||||
env()[varname] = val
|
|
||||||
return val
|
|
||||||
else
|
|
||||||
return nil, val
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
env()[varname] = value
|
||||||
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
function os.remove(...)
|
os.remove = fs.remove
|
||||||
return fs.remove(...)
|
os.rename = fs.rename
|
||||||
end
|
|
||||||
|
|
||||||
function os.rename(...)
|
|
||||||
return fs.rename(...)
|
|
||||||
end
|
|
||||||
|
|
||||||
function os.sleep(timeout)
|
function os.sleep(timeout)
|
||||||
checkArg(1, timeout, "number", "nil")
|
checkArg(1, timeout, "number", "nil")
|
||||||
|
@ -6,7 +6,7 @@ local function onComponentAvailable(_, componentType)
|
|||||||
(componentType == "gpu" and component.isAvailable("screen"))
|
(componentType == "gpu" and component.isAvailable("screen"))
|
||||||
then
|
then
|
||||||
component.gpu.bind(component.screen.address)
|
component.gpu.bind(component.screen.address)
|
||||||
local depth = 2^(component.gpu.getDepth())
|
local depth = math.floor(2^(component.gpu.getDepth()))
|
||||||
os.setenv("TERM", "term-"..depth.."color")
|
os.setenv("TERM", "term-"..depth.."color")
|
||||||
require("computer").pushSignal("gpu_bound", component.gpu.address, component.screen.address)
|
require("computer").pushSignal("gpu_bound", component.gpu.address, component.screen.address)
|
||||||
end
|
end
|
||||||
|
@ -32,6 +32,9 @@ local function components_changed(ename, address, type)
|
|||||||
-- recheck what kb to use
|
-- recheck what kb to use
|
||||||
window.keyboard = nil
|
window.keyboard = nil
|
||||||
end
|
end
|
||||||
|
if (type == "screen" or type == "gpu") and not tty.isAvailable() then
|
||||||
|
computer.pushSignal("term_unavailable")
|
||||||
|
end
|
||||||
elseif (ename == "component_added" or ename == "component_available") and type == "keyboard" then
|
elseif (ename == "component_added" or ename == "component_available") and type == "keyboard" then
|
||||||
-- we need to clear the current terminals cached keyboard (if any) when
|
-- we need to clear the current terminals cached keyboard (if any) when
|
||||||
-- a new keyboard becomes available. This is in case the new keyboard was
|
-- a new keyboard becomes available. This is in case the new keyboard was
|
||||||
@ -43,10 +46,6 @@ local function components_changed(ename, address, type)
|
|||||||
-- primary keyboard is a valid keyboard (weird, in my opinion)
|
-- primary keyboard is a valid keyboard (weird, in my opinion)
|
||||||
window.keyboard = nil
|
window.keyboard = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type == "screen" or type == "gpu") and not tty.isAvailable() then
|
|
||||||
computer.pushSignal("term_unavailable")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
event.listen("component_removed", components_changed)
|
event.listen("component_removed", components_changed)
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
local shell = require("shell")
|
-- there doesn't seem to be a reason to update $HOSTNAME after the init signal
|
||||||
|
-- as user space /etc/profile comes after this point anyways
|
||||||
require("event").listen("init", function()
|
loadfile("/bin/hostname.lua")("--update")
|
||||||
local file = io.open("/etc/hostname")
|
|
||||||
if file then
|
|
||||||
os.setenv("HOSTNAME", file:read("*l"))
|
|
||||||
os.setenv("PS1", "$HOSTNAME:$PWD# ")
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
@ -16,7 +16,7 @@ set HOME=/home
|
|||||||
set IFS=\
|
set IFS=\
|
||||||
set MANPATH=/usr/man:.
|
set MANPATH=/usr/man:.
|
||||||
set PAGER=/bin/more
|
set PAGER=/bin/more
|
||||||
set PS1='$PWD # '
|
set PS1='$HOSTNAME$HOSTNAME_SEPARATOR$PWD # '
|
||||||
set PWD=/
|
set PWD=/
|
||||||
set SHELL=/bin/sh
|
set SHELL=/bin/sh
|
||||||
set LS_COLORS="{FILE=0xFFFFFF,DIR=0x66CCFF,LINK=0xFFAA00,['*.lua']=0x00FF00}"
|
set LS_COLORS="{FILE=0xFFFFFF,DIR=0x66CCFF,LINK=0xFFAA00,['*.lua']=0x00FF00}"
|
||||||
|
@ -20,7 +20,7 @@ function event.register(key, callback, interval, times)
|
|||||||
local handler =
|
local handler =
|
||||||
{
|
{
|
||||||
key = key,
|
key = key,
|
||||||
times = times or math.huge,
|
times = times or 1,
|
||||||
callback = callback,
|
callback = callback,
|
||||||
interval = interval or math.huge,
|
interval = interval or math.huge,
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ function event.listen(name, callback)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return event.register(name, callback)
|
return event.register(name, callback, math.huge, math.huge)
|
||||||
end
|
end
|
||||||
|
|
||||||
function event.onError(message)
|
function event.onError(message)
|
||||||
|
@ -193,8 +193,6 @@ function term.read(history, dobreak, hint, pwchar, filter)
|
|||||||
|
|
||||||
inject_filter(handler, filter)
|
inject_filter(handler, filter)
|
||||||
inject_mask(cursor, dobreak, pwchar)
|
inject_mask(cursor, dobreak, pwchar)
|
||||||
-- todo, make blinking work from here
|
|
||||||
-- handler.blink or w.blink
|
|
||||||
|
|
||||||
return tty.read(handler, cursor)
|
return tty.read(handler, cursor)
|
||||||
end
|
end
|
||||||
|
@ -63,6 +63,7 @@ local function tab_handler(handler, cursor)
|
|||||||
if cache_size == 1 and cache.i == 0 then
|
if cache_size == 1 and cache.i == 0 then
|
||||||
-- there was only one solution, and the user is asking for the next
|
-- there was only one solution, and the user is asking for the next
|
||||||
handler.cache = hints(cache[1], cursor.index + 1)
|
handler.cache = hints(cache[1], cursor.index + 1)
|
||||||
|
if not handler.cache then return end
|
||||||
handler.cache.i = -1
|
handler.cache.i = -1
|
||||||
cache = handler.cache
|
cache = handler.cache
|
||||||
cache_size = #cache
|
cache_size = #cache
|
||||||
|
@ -2,7 +2,7 @@ NAME
|
|||||||
hostname - Display and modify hostname
|
hostname - Display and modify hostname
|
||||||
|
|
||||||
SYNOPIS
|
SYNOPIS
|
||||||
hostname [NEW NAME]
|
hostname [NEW NAME] [--update]
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
hostname
|
hostname
|
||||||
@ -10,3 +10,6 @@ EXAMPLES
|
|||||||
|
|
||||||
hostname test
|
hostname test
|
||||||
Sets hostname of this computer to test
|
Sets hostname of this computer to test
|
||||||
|
|
||||||
|
hostname --update
|
||||||
|
Updates $HOSTNAME by reading /etc/hostname in case it was set manually. Does not print to stdout
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
NAME
|
||||||
|
less - file viewer
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
less [FILE]
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
'less' is a filter for paging through text, as is 'more'. 'less', unlike 'more', support scroll in reverse
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
less example.txt
|
||||||
|
Displays the contents of file `example.txt`
|
||||||
|
find / | less
|
||||||
|
filter the output of `file /` through the 'less' pager
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
more
|
@ -0,0 +1,8 @@
|
|||||||
|
NAME
|
||||||
|
lshw - hardware viewer
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
lshw
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
'lshw' shows you the device information of your PC.
|
@ -0,0 +1,9 @@
|
|||||||
|
NAME
|
||||||
|
rmdir - remove empty directories
|
||||||
|
|
||||||
|
SYNOPIS
|
||||||
|
rmdir [DIRECTORY]
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
rmdir doc
|
||||||
|
Removes doc if and only if doc is an empty directory
|
@ -0,0 +1,19 @@
|
|||||||
|
NAME
|
||||||
|
set - set a environment variable
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
set [VARIABLE]=[VALUE]
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
set an environment variable. Quote [VALUE] to include spaces or non alphanumerics.
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
set
|
||||||
|
Shows all environment variables
|
||||||
|
set example="Hello World"; echo $example
|
||||||
|
Prints Hello World without quotes
|
||||||
|
set LS_COLORS="{FILE=0xFFFFFF,DIR=0x66CCFF,LINK=0xFFAA00,['*.lua']=0xFFFF00}"
|
||||||
|
Change ls colors, showing lua files in yellow. Note ls color defaults are set in /etc/profile
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
unset
|
@ -0,0 +1,15 @@
|
|||||||
|
NAME
|
||||||
|
unset - remove an environment variable
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
unset [VARNAME]
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Removes an environment variable
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
unset some_variable
|
||||||
|
Removes the environment variable some_variable
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
set
|
Loading…
x
Reference in New Issue
Block a user