From 4cedbb41e7910921c16b5878afdc9ea904e2d817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 13 Feb 2015 19:49:13 +0100 Subject: [PATCH] Clean io mode for sh.lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ɓukasz Magiera --- .../assets/opencomputers/loot/OpenOS/bin/sh.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/sh.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/sh.lua index 156c0f0a9..81330372f 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/sh.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/sh.lua @@ -253,6 +253,23 @@ if #args == 0 and (io.input() == io.stdin or options.i) and not options.c then end end end +elseif #args == 0 and (io.input() ~= io.stdin) then + while true do + io.write(expand(os.getenv("PS1") or "$ ")) + local command = io.read("*l") + if not command then + io:write("exit\n") + end + command = text.trim(command) + if command == "exit" then + return + elseif command ~= "" then + local result, reason = os.execute(command) + if not result then + io.stderr:write((tostring(reason) or "unknown error").. "\n") + end + end + end else -- execute command. local result = table.pack(execute(...))