ldoc icon indicating copy to clipboard operation
ldoc copied to clipboard

Add "import" Function and "UNSAFE_NO_SANDBOX" Flag for Accessing Built-in Lua Objects & Functions

Open AntumDeluge opened this issue 4 years ago • 3 comments
trafficstars

Hoping this is a more acceptable solution than #308.

This adds an import function which is enabled with the UNSAFE_NO_SANDBOX command line flag & is used to access built-in Lua objects & functions within the config.ld file.

Example config.ld:

local print = import("print")
local string = import("string")

for _, s in ipairs({string.split("Hello world!")}) do
	print(s)
end

project = "foo"
title = "Bar"
file = {"init.lua"}

Example execution:

ldoc --UNSAFE_NO_SANDBOX .

AntumDeluge avatar Jul 23 '21 20:07 AntumDeluge

Is it necessary to make the flag SCREAM_CASE? I have never seen it used in command arguments. --disable_sandbox fits the current naming scheme and looks better.

nawordar avatar Aug 25 '21 19:08 nawordar

Is it necessary to make the flag SCREAM_CASE?

No.

AntumDeluge avatar Aug 25 '21 23:08 AntumDeluge

I would be okay dropping the use of SCREAM_CASE, but I think we should keep the urgent verbose tone with the words "unsafe" and a negative "no", so --unsafe_no_sandbox. The only other alternative might be to split this into two flags and require both, e.g. --no-sandbox, but require a --unsafe flag to enable unsafe feature(s). If we think there might be more than one we want to warn about like this perhaps that would be best.

alerque avatar Jan 17 '22 11:01 alerque

Changed UNSAFE_NO_SANDBOX to unsafe_no_sandbox.

AntumDeluge avatar May 02 '23 05:05 AntumDeluge