lualoader: Drop excessive parenthesizing

This was also a convenience convention (for me) that is not very lua-tic.
Drop it.

I've maintained some parentheses where I'd prefer them, for example,
'if x or y or (z and w) then', but these situations are far and few between.
This commit is contained in:
Kyle Evans 2018-02-21 01:35:19 +00:00
parent aedd6be5c7
commit 9f71d421c8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329685
8 changed files with 149 additions and 147 deletions

View File

@ -46,35 +46,35 @@ color.DIM = 2
function color.isEnabled()
local c = loader.getenv("loader_color")
if (c ~= nil) then
if (c:lower() == "no") or (c == "0") then
if c ~= nil then
if c:lower() == "no" or c == "0" then
return false
end
end
return (not core.isSerialBoot())
return not core.isSerialBoot()
end
color.disabled = (not color.isEnabled())
color.disabled = not color.isEnabled()
function color.escapef(c)
if (color.disabled) then
if color.disabled then
return c
end
return "\027[3" .. c .. "m"
end
function color.escapeb(c)
if (color.disabled) then
if color.disabled then
return c
end
return "\027[4" .. c .. "m"
end
function color.escape(fg, bg, att)
if (color.disabled) then
if color.disabled then
return ""
end
if (not att) then
if not att then
att = ""
else
att = att .. ";"
@ -83,14 +83,14 @@ function color.escape(fg, bg, att)
end
function color.default()
if (color.disabled) then
if color.disabled then
return ""
end
return "\027[0;37;40m"
end
function color.highlight(str)
if (color.disabled) then
if color.disabled then
return str
end
return "\027[1m" .. str .. "\027[0m"

View File

@ -43,7 +43,7 @@ pattern_table = {
[2] = {
str = "^%s*([%w_]+)_load%s*=%s*\"([%w%s%p]-)\"%s*(.*)",
process = function(k, v)
if (modules[k] == nil) then
if modules[k] == nil then
modules[k] = {}
end
modules[k].load = v:upper()
@ -95,7 +95,7 @@ pattern_table = {
[9] = {
str = "^%s*exec%s*=%s*\"([%w%s%p]-)\"%s*(.*)",
process = function(k, v)
if (loader.perform(k) ~= 0) then
if loader.perform(k) ~= 0 then
print("Failed to exec '" .. k .. "'")
end
end
@ -104,7 +104,7 @@ pattern_table = {
[10] = {
str = "^%s*([%w%p]+)%s*=%s*\"([%w%s%p]-)\"%s*(.*)",
process = function(k, v)
if (config.setenv(k, v) ~= 0) then
if config.setenv(k, v) ~= 0 then
print("Failed to set '" .. k ..
"' with value: " .. v .. "")
end
@ -114,7 +114,7 @@ pattern_table = {
[11] = {
str = "^%s*([%w%p]+)%s*=%s*(%d+)%s*(.*)",
process = function(k, v)
if (config.setenv(k, v) ~= 0) then
if config.setenv(k, v) ~= 0 then
print("Failed to set '" .. k ..
"' with value: " .. v .. "")
end
@ -131,7 +131,7 @@ config.env_restore = {}
-- The first item in every carousel is always the default item.
function config.getCarouselIndex(id)
local val = carousel_choices[id]
if (val == nil) then
if val == nil then
return 1
end
return val
@ -145,18 +145,18 @@ function config.restoreEnv()
-- Examine changed environment variables
for k, v in pairs(config.env_changed) do
local restore_value = config.env_restore[k]
if (restore_value == nil) then
if restore_value == nil then
-- This one doesn't need restored for some reason
goto continue
end
local current_value = loader.getenv(k)
if (current_value ~= v) then
if current_value ~= v then
-- This was overwritten by some action taken on the menu
-- most likely; we'll leave it be.
goto continue
end
restore_value = restore_value.value
if (restore_value ~= nil) then
if restore_value ~= nil then
loader.setenv(k, restore_value)
else
loader.unsetenv(k)
@ -170,7 +170,7 @@ end
function config.setenv(k, v)
-- Track the original value for this if we haven't already
if (config.env_restore[k] == nil) then
if config.env_restore[k] == nil then
config.env_restore[k] = {value = loader.getenv(k)}
end
@ -180,7 +180,7 @@ function config.setenv(k, v)
end
function config.setKey(k, n, v)
if (modules[k] == nil) then
if modules[k] == nil then
modules[k] = {}
end
modules[k][n] = v
@ -196,12 +196,12 @@ end
function config.isValidComment(c)
if (c ~= nil) then
if c ~= nil then
local s = c:match("^%s*#.*")
if (s == nil) then
if s == nil then
s = c:match("^%s*$")
end
if (s == nil) then
if s == nil then
return false
end
end
@ -211,23 +211,23 @@ end
function config.loadmod(mod, silent)
local status = true
for k, v in pairs(mod) do
if (v.load == "YES") then
if v.load == "YES" then
local str = "load "
if (v.flags ~= nil) then
if v.flags ~= nil then
str = str .. v.flags .. " "
end
if (v.type ~= nil) then
if v.type ~= nil then
str = str .. "-t " .. v.type .. " "
end
if (v.name ~= nil) then
if v.name ~= nil then
str = str .. v.name
else
str = str .. k
end
if (v.before ~= nil) then
if (loader.perform(v.before) ~= 0) then
if (not silent) then
if v.before ~= nil then
if loader.perform(v.before) ~= 0 then
if not silent then
print("Failed to execute '" ..
v.before ..
"' before loading '" .. k ..
@ -237,20 +237,20 @@ function config.loadmod(mod, silent)
end
end
if (loader.perform(str) ~= 0) then
if (not silent) then
if loader.perform(str) ~= 0 then
if not silent then
print("Failed to execute '" .. str ..
"'")
end
if (v.error ~= nil) then
if v.error ~= nil then
loader.perform(v.error)
end
status = false
end
if (v.after ~= nil) then
if (loader.perform(v.after) ~= 0) then
if (not silent) then
if v.after ~= nil then
if loader.perform(v.after) ~= 0 then
if not silent then
print("Failed to execute '" ..
v.after ..
"' after loading '" .. k ..
@ -262,7 +262,7 @@ function config.loadmod(mod, silent)
else
-- if not silent then
-- print("Skiping module '". . k .. "'")
-- print("Skipping module '". . k .. "'")
-- end
end
end
@ -272,8 +272,8 @@ end
function config.parse(name, silent)
local f = io.open(name)
if (f == nil) then
if (not silent) then
if f == nil then
if not silent then
print("Failed to open config: '" .. name .. "'")
end
return false
@ -284,8 +284,8 @@ function config.parse(name, silent)
text, r = io.read(f)
if (text == nil) then
if (not silent) then
if text == nil then
if not silent then
print("Failed to read config: '" .. name .. "'")
end
return false
@ -295,15 +295,15 @@ function config.parse(name, silent)
local status = true
for line in text:gmatch("([^\n]+)") do
if (line:match("^%s*$") == nil) then
if line:match("^%s*$") == nil then
local found = false
for i, val in ipairs(pattern_table) do
local k, v, c = line:match(val.str)
if (k ~= nil) then
if k ~= nil then
found = true
if (config.isValidComment(c)) then
if config.isValidComment(c) then
val.process(k, v)
else
print("Malformed line (" .. n ..
@ -315,7 +315,7 @@ function config.parse(name, silent)
end
end
if (found == false) then
if found == false then
print("Malformed line (" .. n .. "):\n\t'" ..
line .. "'")
status = false
@ -336,7 +336,7 @@ function config.loadkernel(other_kernel)
local try_load = function (names)
for name in names:gmatch("([^;]+)%s*;?") do
r = loader.perform("load " .. flags .. " " .. name)
if (r == 0) then
if r == 0 then
return name
end
end
@ -347,7 +347,7 @@ function config.loadkernel(other_kernel)
local bootfile = loader.getenv("bootfile")
-- append default kernel name
if (bootfile == nil) then
if bootfile == nil then
bootfile = "kernel"
else
bootfile = bootfile .. ";kernel"
@ -357,10 +357,10 @@ function config.loadkernel(other_kernel)
end
-- kernel not set, try load from default module_path
if (kernel == nil) then
if kernel == nil then
local res = load_bootfile()
if (res ~= nil) then
if res ~= nil then
-- Default kernel is loaded
config.kernel_loaded = nil
return true
@ -374,7 +374,7 @@ function config.loadkernel(other_kernel)
local module_path = config.module_path
local res = nil
if (other_kernel ~= nil) then
if other_kernel ~= nil then
kernel = other_kernel
end
-- first try load kernel with module_path = /boot/${kernel}
@ -386,9 +386,9 @@ function config.loadkernel(other_kernel)
res = load_bootfile()
-- succeeded, add path to module_path
if (res ~= nil) then
if res ~= nil then
config.kernel_loaded = kernel
if (module_path ~= nil) then
if module_path ~= nil then
loader.setenv("module_path", v .. ";" ..
module_path)
end
@ -399,7 +399,7 @@ function config.loadkernel(other_kernel)
-- failed to load with ${kernel} as a directory
-- try as a file
res = try_load(kernel)
if (res ~= nil) then
if res ~= nil then
config.kernel_loaded = kernel
return true
else
@ -414,18 +414,20 @@ function config.selectkernel(kernel)
end
function config.load(file)
if (not file) then
if not file then
file = "/boot/defaults/loader.conf"
end
if (not config.parse(file)) then
if not config.parse(file) then
-- XXX TODO: Why is this commented out?
-- print("Failed to parse configuration: '" .. file .. "'")
end
local f = loader.getenv("loader_conf_files")
if (f ~= nil) then
if f ~= nil then
for name in f:gmatch("([%w%p]+)%s*") do
if (not config.parse(name)) then
if not config.parse(name) then
-- XXX TODO: Ditto the above
-- print("Failed to parse configuration: '" ..
-- name .. "'")
end
@ -450,13 +452,13 @@ function config.loadelf()
print("Loading kernel...")
loaded = config.loadkernel(kernel)
if (not loaded) then
if not loaded then
print("Failed to load any kernel")
return
end
print("Loading configured modules...")
if (not config.loadmod(modules)) then
if not config.loadmod(modules) then
print("Could not load one or more modules!")
end
end

View File

@ -31,7 +31,7 @@ local config = require('config')
local core = {}
local compose_loader_cmd = function(cmd_name, argstr)
if (argstr ~= nil) then
if argstr ~= nil then
cmd_name = cmd_name .. " " .. argstr
end
return cmd_name
@ -43,23 +43,23 @@ end
-- This will also parse arguments to autoboot, but the with_kernel argument
-- will need to be explicitly overwritten to false
local parse_boot_args = function(argv, with_kernel)
if (#argv == 0) then
if #argv == 0 then
return nil, ""
end
if (with_kernel == nil) then
if with_kernel == nil then
with_kernel = true
end
local kernel_name
local argstr = ""
for k, v in ipairs(argv) do
if (with_kernel) and (v:sub(1,1) ~= "-") then
if with_kernel and v:sub(1,1) ~= "-" then
kernel_name = v
else
argstr = argstr .. " " .. v
end
end
if (with_kernel) then
if with_kernel then
return kernel_name, argstr
else
return argstr
@ -72,7 +72,7 @@ function boot(...)
local cmd_name = ""
cmd_name, argv = core.popFrontTable(argv)
local kernel, argstr = parse_boot_args(argv)
if (kernel ~= nil) then
if kernel ~= nil then
loader.perform("unload")
config.selectkernel(kernel)
end
@ -102,11 +102,11 @@ core.MENU_SUBMENU = "submenu"
core.MENU_CAROUSEL_ENTRY = "carousel_entry"
function core.setVerbose(b)
if (b == nil) then
if b == nil then
b = not core.verbose
end
if (b == true) then
if b == true then
loader.setenv("boot_verbose", "YES")
else
loader.unsetenv("boot_verbose")
@ -115,11 +115,11 @@ function core.setVerbose(b)
end
function core.setSingleUser(b)
if (b == nil) then
if b == nil then
b = not core.su
end
if (b == true) then
if b == true then
loader.setenv("boot_single", "YES")
else
loader.unsetenv("boot_single")
@ -130,23 +130,23 @@ end
function core.getACPIPresent(checkingSystemDefaults)
local c = loader.getenv("hint.acpi.0.rsdp")
if (c ~= nil) then
if (checkingSystemDefaults == true) then
if c ~= nil then
if checkingSystemDefaults == true then
return true
end
-- Otherwise, respect disabled if it's set
c = loader.getenv("hint.acpi.0.disabled")
return (c == nil) or (tonumber(c) ~= 1)
return c == nil or tonumber(c) ~= 1
end
return false
end
function core.setACPI(b)
if (b == nil) then
if b == nil then
b = not core.acpi
end
if (b == true) then
if b == true then
loader.setenv("acpi_load", "YES")
loader.setenv("hint.acpi.0.disabled", "0")
loader.unsetenv("loader.acpi_disabled_by_user")
@ -159,10 +159,10 @@ function core.setACPI(b)
end
function core.setSafeMode(b)
if (b == nil) then
if b == nil then
b = not core.sm
end
if (b == true) then
if b == true then
loader.setenv("kern.smp.disabled", "1")
loader.setenv("hw.ata.ata_dma", "0")
loader.setenv("hw.ata.atapi_dma", "0")
@ -189,14 +189,14 @@ function core.kernelList()
local kernels = {}
local unique = {}
local i = 0
if (k ~= nil) then
if k ~= nil then
i = i + 1
kernels[i] = k
unique[k] = true
end
for n in v:gmatch("([^; ]+)[; ]?") do
if (unique[n] == nil) then
if unique[n] == nil then
i = i + 1
kernels[i] = n
unique[n] = true
@ -209,19 +209,19 @@ function core.kernelList()
for file in lfs.dir("/boot") do
local fname = "/boot/" .. file
if (file == "." or file == "..") then
if file == "." or file == ".." then
goto continue
end
if (lfs.attributes(fname, "mode") ~= "directory") then
if lfs.attributes(fname, "mode") ~= "directory" then
goto continue
end
if (lfs.attributes(fname .. "/kernel", "mode") ~= "file") then
if lfs.attributes(fname .. "/kernel", "mode") ~= "file" then
goto continue
end
if (unique[file] == nil) then
if unique[file] == nil then
i = i + 1
kernels[i] = file
unique[file] = true
@ -257,33 +257,33 @@ end
function core.isSerialBoot()
local c = loader.getenv("console")
if (c ~= nil) then
if (c:find("comconsole") ~= nil) then
if c ~= nil then
if c:find("comconsole") ~= nil then
return true
end
end
local s = loader.getenv("boot_serial")
if (s ~= nil) then
if s ~= nil then
return true
end
local m = loader.getenv("boot_multicons")
if (m ~= nil) then
if m ~= nil then
return true
end
return false
end
function core.isSystem386()
return (loader.machine_arch == "i386")
return loader.machine_arch == "i386"
end
-- This may be a better candidate for a 'utility' module.
function core.shallowCopyTable(tbl)
local new_tbl = {}
for k, v in pairs(tbl) do
if (type(v) == "table") then
if type(v) == "table" then
new_tbl[k] = core.shallowCopyTable(v)
else
new_tbl[k] = v
@ -297,9 +297,9 @@ end
-- for our uses
function core.popFrontTable(tbl)
-- Shouldn't reasonably happen
if (#tbl == 0) then
if #tbl == 0 then
return nil, nil
elseif (#tbl == 1) then
elseif #tbl == 1 then
return tbl[1], {}
end
@ -307,7 +307,7 @@ function core.popFrontTable(tbl)
local new_tbl = {}
-- This is not a cheap operation
for k, v in ipairs(tbl) do
if (k > 1) then
if k > 1 then
new_tbl[k - 1] = v
end
end
@ -319,7 +319,7 @@ end
-- generally be set upon execution of the kernel. Because of this, we can't (or
-- don't really want to) detect/disable ACPI on !i386 reliably. Just set it
-- enabled if we detect it and leave well enough alone if we don't.
if (core.isSystem386()) and (core.getACPIPresent(false)) then
if core.isSystem386() and core.getACPIPresent(false) then
core.setACPI(true)
end
return core

View File

@ -45,7 +45,7 @@ local none_shifted = false
local menu_entry_name = function(drawing_menu, entry)
local name_handler = drawer.menu_name_handlers[entry.entry_type]
if (name_handler ~= nil) then
if name_handler ~= nil then
return name_handler(drawing_menu, entry)
end
return entry.name()
@ -180,7 +180,7 @@ drawer.menu_name_handlers = {
local caridx = config.getCarouselIndex(carid)
local choices = entry.items()
if (#choices < caridx) then
if #choices < caridx then
caridx = 1
end
return entry.name(caridx, choices[caridx], choices)
@ -256,16 +256,16 @@ function drawer.drawmenu(m)
local alias_table = {}
local entry_num = 0
local menu_entries = m.entries
if (type(menu_entries) == "function") then
if type(menu_entries) == "function" then
menu_entries = menu_entries()
end
for line_num, e in ipairs(menu_entries) do
-- Allow menu items to be conditionally visible by specifying
-- a visible function.
if (e.visible ~= nil) and (not e.visible()) then
if e.visible ~= nil and not e.visible() then
goto continue
end
if (e.entry_type ~= core.MENU_SEPARATOR) then
if e.entry_type ~= core.MENU_SEPARATOR then
entry_num = entry_num + 1
screen.setcursor(x, y + line_num)
@ -273,7 +273,7 @@ function drawer.drawmenu(m)
-- fill the alias table
alias_table[tostring(entry_num)] = e
if (e.alias ~= nil) then
if e.alias ~= nil then
for n, a in ipairs(e.alias) do
alias_table[a] = e
end
@ -339,7 +339,7 @@ function drawer.drawbrand()
drawer.brand_position.y
local graphic = drawer.branddefs[loader.getenv("loader_brand")]
if (graphic == nil) then
if graphic == nil then
graphic = fbsd_logo
end
drawer.draw(x, y, graphic)
@ -357,22 +357,22 @@ function drawer.drawlogo()
-- Lookup
local logodef = drawer.logodefs[logo]
if (logodef ~= nil) and (logodef.graphic == none) then
if logodef ~= nil and logodef.graphic == none then
-- centre brand and text if no logo
if (not none_shifted) then
if not none_shifted then
shift_brand_text(logodef.shift)
none_shifted = true
end
elseif (logodef == nil) or (logodef.graphic == nil) or
((not colored) and logodef.requires_color) then
elseif logodef == nil or logodef.graphic == nil or
(not colored and logodef.requires_color) then
-- Choose a sensible default
if (colored) then
if colored then
logodef = drawer.logodefs["orb"]
else
logodef = drawer.logodefs["orbbw"]
end
end
if (logodef.shift ~= nil) then
if logodef.shift ~= nil then
x = x + logodef.shift.x
y = y + logodef.shift.y
end

View File

@ -37,14 +37,14 @@ local password = require("password")
function cli_execute(...)
local argv = {...}
-- Just in case...
if (#argv == 0) then
if #argv == 0 then
loader.command(...)
return
end
local cmd_name = argv[1]
local cmd = _G[cmd_name]
if (cmd ~= nil) and (type(cmd) == "function") then
if cmd ~= nil and type(cmd) == "function" then
-- Pass argv wholesale into cmd. We could omit argv[0] since the
-- traditional reasons for including it don't necessarily apply,
-- it may not be totally redundant if we want to have one global

View File

@ -41,7 +41,7 @@ local run
local autoboot
local OnOff = function(str, b)
if (b) then
if b then
return str .. color.escapef(color.GREEN) .. "On" ..
color.escapef(color.WHITE)
else
@ -67,7 +67,7 @@ menu.handlers = {
local caridx = config.getCarouselIndex(carid)
local choices = entry.items()
if (#choices > 0) then
if #choices > 0 then
caridx = (caridx % #choices) + 1
config.setCarouselIndex(carid, caridx)
entry.func(caridx, choices[caridx], choices)
@ -79,7 +79,7 @@ menu.handlers = {
end,
[core.MENU_RETURN] = function(current_menu, entry)
-- allow entry to have a function/side effect
if (entry.func ~= nil) then
if entry.func ~= nil then
entry.func()
end
return false
@ -181,9 +181,9 @@ menu.welcome = {
entries = function()
local menu_entries = menu.welcome.all_entries
-- Swap the first two menu items on single user boot
if (core.isSingleUserBoot()) then
if core.isSingleUserBoot() then
-- We'll cache the swapped menu, for performance
if (menu.welcome.swapped_menu ~= nil) then
if menu.welcome.swapped_menu ~= nil then
return menu.welcome.swapped_menu
end
-- Shallow copy the table
@ -287,14 +287,14 @@ menu.welcome = {
carousel_id = "kernel",
items = core.kernelList,
name = function(idx, choice, all_choices)
if (#all_choices == 0) then
if #all_choices == 0 then
return "Kernel: "
end
local is_default = (idx == 1)
local kernel_name = ""
local name_color
if (is_default) then
if is_default then
name_color = color.escapef(color.GREEN)
kernel_name = "default/"
else
@ -329,12 +329,12 @@ menu.welcome = {
function menu.run(m)
if (menu.skip()) then
if menu.skip() then
core.autoboot()
return false
end
if (m == nil) then
if m == nil then
m = menu.welcome
end
@ -346,14 +346,14 @@ function menu.run(m)
menu.autoboot()
cont = true
while (cont) do
while cont do
local key = io.getchar()
-- Special key behaviors
if ((key == core.KEY_BACKSPACE) or (key == core.KEY_DELETE)) and
(m ~= menu.welcome) then
if (key == core.KEY_BACKSPACE or key == core.KEY_DELETE) and
m ~= menu.welcome then
break
elseif (key == core.KEY_ENTER) then
elseif key == core.KEY_ENTER then
core.boot()
-- Should not return
end
@ -362,21 +362,21 @@ function menu.run(m)
-- check to see if key is an alias
local sel_entry = nil
for k, v in pairs(alias_table) do
if (key == k) then
if key == k then
sel_entry = v
end
end
-- if we have an alias do the assigned action:
if (sel_entry ~= nil) then
if sel_entry ~= nil then
-- Get menu handler
local handler = menu.handlers[sel_entry.entry_type]
if (handler ~= nil) then
if handler ~= nil then
-- The handler's return value indicates whether
-- we need to exit this menu. An omitted return
-- value means "continue" by default.
cont = handler(m, sel_entry)
if (cont == nil) then
if cont == nil then
cont = true
end
end
@ -387,7 +387,7 @@ function menu.run(m)
end
end
if (m == menu.welcome) then
if m == menu.welcome then
screen.defcursor()
print("Exiting menu!")
return false
@ -397,11 +397,11 @@ function menu.run(m)
end
function menu.skip()
if (core.isSerialBoot()) then
if core.isSerialBoot() then
return true
end
local c = string.lower(loader.getenv("console") or "")
if ((c:match("^efi[ ;]") or c:match("[ ;]efi[ ;]")) ~= nil) then
if c:match("^efi[ ;]") ~= nil or c:match("[ ;]efi[ ;]") ~= nil then
return true
end
@ -411,15 +411,15 @@ function menu.skip()
end
function menu.autoboot()
if (menu.already_autoboot == true) then
if menu.already_autoboot == true then
return
end
menu.already_autoboot = true
local ab = loader.getenv("autoboot_delay")
if (ab ~= nil) and (ab:lower() == "no") then
if ab ~= nil and ab:lower() == "no" then
return
elseif (tonumber(ab) == -1) then
elseif tonumber(ab) == -1 then
core.boot()
end
ab = tonumber(ab) or 10
@ -437,9 +437,9 @@ function menu.autoboot()
" seconds, hit [Enter] to boot" ..
" or any other key to stop ")
screen.defcursor()
if (io.ischar()) then
if io.ischar() then
local ch = io.getchar()
if (ch == core.KEY_ENTER) then
if ch == core.KEY_ENTER then
break
else
-- erase autoboot msg

View File

@ -39,13 +39,13 @@ function password.read()
repeat
ch = io.getchar()
if (ch == core.KEY_ENTER) then
if ch == core.KEY_ENTER then
break
end
-- XXX TODO: Evaluate if we really want this or not, as a
-- security consideration of sorts
if (ch == core.KEY_BACKSPACE) or (ch == core.KEY_DELETE) then
if (n > 0) then
if ch == core.KEY_BACKSPACE or ch == core.KEY_DELETE then
if n > 0 then
n = n - 1
-- loader.printc("\008 \008")
str = str:sub(1, n)
@ -55,7 +55,7 @@ function password.read()
str = str .. string.char(ch)
n = n + 1
end
until (n == 16)
until n == 16
return str
end
@ -64,10 +64,10 @@ function password.check()
screen.defcursor()
-- pwd is optionally supplied if we want to check it
local function do_prompt(prompt, pwd)
while (true) do
while true do
loader.printc(prompt)
local read_pwd = password.read()
if (not pwd) or (pwd == read_pwd) then
if pwd == nil or pwd == read_pwd then
-- Throw an extra newline after password prompt
print("")
return read_pwd
@ -77,7 +77,7 @@ function password.check()
end
end
local function compare(prompt, pwd)
if (pwd == nil) then
if pwd == nil then
return
end
do_prompt(prompt, pwd)
@ -87,13 +87,13 @@ function password.check()
compare("Boot password: ", boot_pwd)
local geli_prompt = loader.getenv("geom_eli_passphrase_prompt")
if (geli_prompt ~= nil) and (geli_prompt:lower() == "yes") then
if geli_prompt ~= nil and geli_prompt:lower() == "yes" then
local passphrase = do_prompt("GELI Passphrase: ")
loader.setenv("kern.geom.eli.passphrase", passphrase)
end
local pwd = loader.getenv("password")
if (pwd ~= nil) then
if pwd ~= nil then
core.autoboot()
end
compare("Password: ", pwd)

View File

@ -36,7 +36,7 @@ local intstring = function(num)
local str = tostring(num)
local decimal = str:find("%.")
if (decimal) then
if decimal then
return str:sub(1, decimal - 1)
end
return str
@ -44,14 +44,14 @@ end
-- Module exports
function screen.clear()
if (core.isSerialBoot()) then
if core.isSerialBoot() then
return
end
loader.printc("\027[H\027[J")
end
function screen.setcursor(x, y)
if (core.isSerialBoot()) then
if core.isSerialBoot() then
return
end
@ -59,14 +59,14 @@ function screen.setcursor(x, y)
end
function screen.setforeground(c)
if (color.disabled) then
if color.disabled then
return c
end
loader.printc("\027[3" .. c .. "m")
end
function screen.setbackground(c)
if (color.disabled) then
if color.disabled then
return c
end
loader.printc("\027[4" .. c .. "m")
@ -77,7 +77,7 @@ function screen.defcolor()
end
function screen.defcursor()
if (core.isSerialBoot()) then
if core.isSerialBoot() then
return
end
loader.printc("\027[25;0H")