mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-19 12:17:17 -04:00
Made Histrory Length a EnvVar
Well, there is it!
This commit is contained in:
parent
fe08db56cc
commit
8ca7306f34
@ -7,6 +7,14 @@ local shell = require("shell")
|
|||||||
local term = require("term")
|
local term = require("term")
|
||||||
local text = require("text")
|
local text = require("text")
|
||||||
|
|
||||||
|
local function getHistSize()
|
||||||
|
if os.getenv("HISTSIZE") then
|
||||||
|
return os.getenv("HISTSIZE")
|
||||||
|
else
|
||||||
|
return 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function expand(value)
|
local function expand(value)
|
||||||
local result = value:gsub("%$(%w+)", os.getenv):gsub("%$%b{}",
|
local result = value:gsub("%$(%w+)", os.getenv):gsub("%$%b{}",
|
||||||
function(match) return os.getenv(expand(match:sub(3, -2))) or match end)
|
function(match) return os.getenv(expand(match:sub(3, -2))) or match end)
|
||||||
@ -165,7 +173,7 @@ if #args == 0 and (io.input() == io.stdin or options.i) and not options.c then
|
|||||||
term.write("exit\n")
|
term.write("exit\n")
|
||||||
return -- eof
|
return -- eof
|
||||||
end
|
end
|
||||||
while #history > 20 do
|
while #history > getHistSize() do
|
||||||
table.remove(history, 1)
|
table.remove(history, 1)
|
||||||
end
|
end
|
||||||
command = text.trim(command)
|
command = text.trim(command)
|
||||||
|
@ -16,6 +16,7 @@ local env = {
|
|||||||
SHELL="/bin/sh",
|
SHELL="/bin/sh",
|
||||||
TMP="/tmp", -- Depricated
|
TMP="/tmp", -- Depricated
|
||||||
TMPDIR="/tmp"
|
TMPDIR="/tmp"
|
||||||
|
HISTSIZE=10
|
||||||
}
|
}
|
||||||
|
|
||||||
os.execute = function(command)
|
os.execute = function(command)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user