mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
check for non-existant file in bin/moon, write error to stderr
This commit is contained in:
parent
bdb69566f9
commit
7d2f57d9f2
14
bin/moon
14
bin/moon
@ -16,6 +16,11 @@ local help = [=[Usage: %s [options] [script [args]]
|
|||||||
-v Print version
|
-v Print version
|
||||||
]=]
|
]=]
|
||||||
|
|
||||||
|
local function print_err(...)
|
||||||
|
msg = table.concat({...}, "\t")
|
||||||
|
io.stderr:write(msg .. "\n")
|
||||||
|
end
|
||||||
|
|
||||||
local function print_help(err)
|
local function print_help(err)
|
||||||
if err then print("Error: "..err) end
|
if err then print("Error: "..err) end
|
||||||
print(help:format(arg[0]))
|
print(help:format(arg[0]))
|
||||||
@ -48,7 +53,12 @@ local passed, err = pcall(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
if not passed then
|
if not passed then
|
||||||
print(err)
|
print_err(err)
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not moonscript_chunk then
|
||||||
|
print_err("Can't find file: " .. script_fname)
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -64,7 +74,7 @@ if not opts.d then
|
|||||||
if err then
|
if err then
|
||||||
local traceback = util.trim(trace)
|
local traceback = util.trim(trace)
|
||||||
traceback = moonscript.errors.truncate_traceback(traceback)
|
traceback = moonscript.errors.truncate_traceback(traceback)
|
||||||
print(moonscript.errors.rewrite_traceback(traceback, err))
|
print_err(moonscript.errors.rewrite_traceback(traceback, err))
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user