From 5461bd179be52d71a3300c1b60dd408b151d8da7 Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Thu, 26 Dec 2013 22:47:11 -0800 Subject: [PATCH] keep help on stdout unless error --- bin/moonc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/moonc b/bin/moonc index 0e2e2f7..7ce00f3 100755 --- a/bin/moonc +++ b/bin/moonc @@ -40,12 +40,16 @@ if opts.v then end function print_help(err) + local help_msg = help:format(arg[0]) + if err then io.stderr:write("Error: ".. err .. "\n") + io.stderr:write(help_msg .. "\n") + os.exit(1) + else + print(help_msg) + os.exit(0) end - - io.stderr:write(help:format(arg[0]) .. "\n") - os.exit(1) end function mkdir(path)