mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 19:56:17 -04:00
allow .shrc to use tty stdin
This commit is contained in:
parent
5107afb176
commit
f26cb54c28
@ -17,13 +17,20 @@ if not file then
|
||||
return 1
|
||||
end
|
||||
|
||||
local current_data = process.info().data
|
||||
local lines = file:lines()
|
||||
|
||||
local source_proc = process.load((assert(os.getenv("SHELL"), "no $SHELL set")))
|
||||
local source_data = process.list[source_proc].data
|
||||
source_data.aliases = current_data.aliases -- hacks to propogate sub shell env changes
|
||||
source_data.vars = current_data.vars
|
||||
source_data.io[0] = file -- set stdin to the file
|
||||
process.internal.continue(source_proc, "-c")
|
||||
while true do
|
||||
local line = lines()
|
||||
if not line then
|
||||
break
|
||||
end
|
||||
local current_data = process.info().data
|
||||
|
||||
local source_proc = process.load((assert(os.getenv("SHELL"), "no $SHELL set")))
|
||||
local source_data = process.list[source_proc].data
|
||||
source_data.aliases = current_data.aliases -- hacks to propogate sub shell env changes
|
||||
source_data.vars = current_data.vars
|
||||
process.internal.continue(source_proc, _ENV, line)
|
||||
end
|
||||
|
||||
file:close() -- should have closed when the process closed, but just to be sure
|
||||
file:close()
|
||||
|
@ -38,6 +38,6 @@ os.setenv("LS_COLORS", "di=0;36:fi=0:ln=0;33:*.lua=0;32")
|
||||
shell.setWorkingDirectory(os.getenv("HOME"))
|
||||
|
||||
local home_shrc = shell.resolve(".shrc")
|
||||
if fs.exists(home_shrc) then
|
||||
if fs.size(home_shrc) > 0 then
|
||||
loadfile(shell.resolve("source", "lua"))(home_shrc)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user