Add setting bios.shell_path

Allow the user to directly set the path the bios uses for the shell.

Has some additional status checking to allow for shell errors to be read before computer shutdown.
This commit is contained in:
hugeblank 2024-04-19 10:12:08 -07:00
parent 776fa00b94
commit 6d32c98a69
1 changed files with 23 additions and 9 deletions

View File

@ -697,6 +697,20 @@ if term.isColour() then
type = "boolean", type = "boolean",
}) })
end end
local sShell
if term.isColour() and settings.get("bios.use_multishell") then
sShell = "rom/programs/advanced/multishell.lua"
else
sShell = "rom/programs/shell.lua"
end
settings.define("bios.shell_path", {
default = sShell,
description = "The path the bios executes as the shell. This program is responsible for implementing the shell and multishell API, handling user input, and program execution.",
type = "string"
})
if _CC_DEFAULT_SETTINGS then if _CC_DEFAULT_SETTINGS then
for sPair in string.gmatch(_CC_DEFAULT_SETTINGS, "[^,]+") do for sPair in string.gmatch(_CC_DEFAULT_SETTINGS, "[^,]+") do
local sName, sValue = string.match(sPair, "([^=]*)=(.*)") local sName, sValue = string.match(sPair, "([^=]*)=(.*)")
@ -728,24 +742,24 @@ if fs.exists(".settings") then
end end
-- Run the shell -- Run the shell
local shellOk
local ok, err = pcall(parallel.waitForAny, local ok, err = pcall(parallel.waitForAny,
function() function()
local sShell shellOk = os.run({}, settings.get("bios.shell_path"))
if term.isColour() and settings.get("bios.use_multishell") then if shellOk then
sShell = "rom/programs/advanced/multishell.lua" os.run({}, "rom/programs/shutdown.lua")
else
sShell = "rom/programs/shell.lua"
end end
os.run({}, sShell)
os.run({}, "rom/programs/shutdown.lua")
end, end,
rednet.run rednet.run
) )
-- If the shell errored, let the user read it. -- If the shell errored, let the user read it.
term.redirect(term.native()) term.redirect(term.native())
if not ok then if not (ok and shellOk) then
printError(err) -- if the shell within os.run errored, then the error was already output, and the shell loop exited normally.
if not ok then
printError(err)
end
pcall(function() pcall(function()
term.setCursorBlink(false) term.setCursorBlink(false)
print("Press any key to continue") print("Press any key to continue")