freebsd-nq/stand/lua
Kyle Evans 576562856e lualoader: improve loader.conf var processing
lualoader was previously not processing \ as escapes; this commit fixes
that and does better error checking on the value as well.

Additionally, loader.conf had some odd restrictions on values that make
little sense. Previously, lines like:

kernel=foo

Would simply be discarded with a malformed line complaint you might not
see unless you disable beastie.

lualoader tries to process these as well as it can and manipulates the
environment, while forthloader did minimal processing and constructed a
`set` command to do the heavy lifting instead. The lua approach was
re-envisioned from building a `set` command so that we can appropriately
reset the environment when, for example, boot environments change.

Lift the previous restrictions to allow unquoted values on the right hand
side of an expression.  Note that an unquoted value is effectively:

[A-Za-z0-9-][A-Za-z0-9-_.]*

This commit also stops trying to weirdly limit what it can handle in a
quoted value. Previously it only allowed spaces, alphanumeric, and
punctuation, which is kind of weird. Change it here to grab as much as it
can between two sets of quotes, then let processEnvVar() do the needful and
complain if it finds something malformed looking.

My extremely sophisticated test suite is as follows:

<<EOF
X_01_simple_string="simple"
X_02_escaped_string="s\imple"

X_03_unquoted_val=3
X_04_unquoted_strval=simple_test

X_05_subval="${X_03_unquoted_val}"
X_06_escaped_subval="\${X_03_unquoted_val}"

X_07_embedded="truth${X_03_unquoted_val}"
X_08_escaped_embedded="truth\${X_03_unquoted_val}"

X_09_unknown="${unknown_val}"
X_10_unknown_embedded="truth${unknown_val}"

X_11_crunchy="crunch$unknown_val crunch"
X_12_crunchy="crunch${unknown_val}crunch"

Y_01_badquote="te"lol"
Y_02_eolesc="lol\"
Y_02_noteolesc="lol\\"
Y_03_eolvar="lol$"
Y_03_noteolvar="lol\$"
Y_04_badvar="lol${"

exec="echo Done!"
EOF

Future work may provide a stub loader module in userland so that we can
formally test the loader scripts rather than sketchy setups like the above
in conjunction with the lua-* tools in ^/tools/boot.
2021-01-24 13:54:47 -06:00
..
cli.lua lualoader: fix lua-lint run 2020-12-17 18:29:30 +00:00
cli.lua.8 lualoader: cli: provide a show-module-options loader command 2020-12-17 18:24:36 +00:00
color.lua loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
color.lua.8 Add color.lua(8), password.lua(8), and screen.lua(8) 2018-08-20 02:37:24 +00:00
config.lua lualoader: improve loader.conf var processing 2021-01-24 13:54:47 -06:00
config.lua.8 lualoader: cli: provide a show-module-options loader command 2020-12-17 18:24:36 +00:00
core.lua loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
core.lua.8 Eliminate zfsloader man page. 2018-07-20 05:17:49 +00:00
drawer.lua lualoader: use floor division to get correct type 2021-01-15 15:02:38 -06:00
drawer.lua.8 Add drawer.lua(8) 2018-08-20 02:08:39 +00:00
gfx-beastie.lua lualoader: improve the design of the brand-/logo- mechanism 2020-10-04 22:41:43 +00:00
gfx-beastiebw.lua lualoader: improve the design of the brand-/logo- mechanism 2020-10-04 22:41:43 +00:00
gfx-fbsdbw.lua lualoader: improve the design of the brand-/logo- mechanism 2020-10-04 22:41:43 +00:00
gfx-orb.lua loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
gfx-orbbw.lua lualoader: improve the design of the brand-/logo- mechanism 2020-10-04 22:41:43 +00:00
hook.lua Remove "All Rights Reserved" on files that I hold sole copyright on 2018-05-09 16:44:19 +00:00
hook.lua.8 lualoader: Add hook.lua(8) to tree 2018-06-09 14:26:30 +00:00
loader.lua loader: Fully reset terminal settings, not just colors 2020-03-27 17:37:31 +00:00
Makefile lualoader: improve the design of the brand-/logo- mechanism 2020-10-04 22:41:43 +00:00
menu.lua lualoader: clear up some luacheck warnings 2020-10-01 14:20:36 +00:00
menu.lua.8 Remove "All Rights Reserved" on files that I hold sole copyright on 2018-05-09 16:44:19 +00:00
password.lua Further normalize copyright notices 2019-09-26 16:19:22 +00:00
password.lua.8 Add color.lua(8), password.lua(8), and screen.lua(8) 2018-08-20 02:37:24 +00:00
screen.lua lualoader: don't botch disabling of color 2019-10-21 20:09:43 +00:00
screen.lua.8 Add color.lua(8), password.lua(8), and screen.lua(8) 2018-08-20 02:37:24 +00:00