From: Tobias Ulmer Date: Mon, 22 Apr 2013 14:18:07 +0000 (+0200) Subject: Handle errors from e2option.parse() X-Git-Tag: e2factory-2.3.15rc1~519 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=d1d162b48ffc156b1a43442f7adb7aac9b3d9703;p=e2factory.git Handle errors from e2option.parse() Signed-off-by: Tobias Ulmer --- diff --git a/global/e2-create-project.lua b/global/e2-create-project.lua index bb1137c..d3f3c09 100644 --- a/global/e2-create-project.lua +++ b/global/e2-create-project.lua @@ -39,6 +39,10 @@ local function e2_create_project(arg) e2lib.init() local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end + local rc, e = e2lib.read_global_config() if not rc then return false, e diff --git a/global/e2-fetch-project.lua b/global/e2-fetch-project.lua index f9784b0..6d8db9d 100644 --- a/global/e2-fetch-project.lua +++ b/global/e2-fetch-project.lua @@ -43,6 +43,10 @@ local function e2_fetch_project(arg) e2option.option("tag", "retrieve a specific project tag") local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end + local rc, re = e2lib.read_global_config() if not rc then return false, e:cat(re) diff --git a/global/e2-install-e2.lua b/global/e2-install-e2.lua index a64f232..3960751 100644 --- a/global/e2-install-e2.lua +++ b/global/e2-install-e2.lua @@ -38,6 +38,9 @@ local function e2_install_e2(arg) e2lib.init() local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end local root = e2lib.locate_project_root() if not root then diff --git a/global/e2.lua b/global/e2.lua index 2c7f84d..24b6dd2 100644 --- a/global/e2.lua +++ b/global/e2.lua @@ -58,7 +58,11 @@ local function e2(arg) e2call.arg_string = quoteargs(table.concat(arg, "' '", 2)) elseif e2call.basename == "e2" then e2call.toolname = "e2" - local opts = e2option.parse(arg) + local opts, re = e2option.parse(arg) + if not opts then + return false, re + end + if #opts == 0 then e2option.usage(1) end diff --git a/local/e2-build.lua b/local/e2-build.lua index a7e90f3..08739bb 100644 --- a/local/e2-build.lua +++ b/local/e2-build.lua @@ -90,6 +90,9 @@ local function e2_build(arg) enable_writeback, "SERVER") local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end -- get build mode from the command line local build_mode, re = policy.handle_commandline_options(opts, true) diff --git a/local/e2-cf.lua b/local/e2-cf.lua index 8014ed4..ac60d1e 100644 --- a/local/e2-cf.lua +++ b/local/e2-cf.lua @@ -324,6 +324,9 @@ local function e2_cf(arg) end local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end -- initialize some basics in the info structure without actually loading -- the project configuration. diff --git a/local/e2-dlist.lua b/local/e2-dlist.lua index 37f9846..d64672f 100644 --- a/local/e2-dlist.lua +++ b/local/e2-dlist.lua @@ -41,6 +41,9 @@ local function e2_dlist(arg) e2option.flag("recursive", "show indirect dependencies, too") local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end if #arguments == 0 then return false, diff --git a/local/e2-dsort.lua b/local/e2-dsort.lua index 1251262..7aee799 100644 --- a/local/e2-dsort.lua +++ b/local/e2-dsort.lua @@ -39,7 +39,10 @@ local function e2_dsort(arg) return false, re end - e2option.parse(arg) + local opts, re = e2option.parse(arg) + if not opts then + return false, re + end info, re = e2tool.collect_project_info(info) if not info then diff --git a/local/e2-fetch-sources.lua b/local/e2-fetch-sources.lua index fde3612..6168355 100644 --- a/local/e2-fetch-sources.lua +++ b/local/e2-fetch-sources.lua @@ -58,6 +58,10 @@ local function e2_fetch_source(arg) e2option.flag("result", "select sources by result names") local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end + info, re = e2tool.collect_project_info(info) if not info then return false, info diff --git a/local/e2-help.lua b/local/e2-help.lua index 97491fb..0b2dcaa 100644 --- a/local/e2-help.lua +++ b/local/e2-help.lua @@ -240,6 +240,9 @@ local function e2_help(arg) end local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end info, re = e2tool.collect_project_info(info, true) if not info then diff --git a/local/e2-ls-project.lua b/local/e2-ls-project.lua index 8731ad4..4cd9d76 100644 --- a/local/e2-ls-project.lua +++ b/local/e2-ls-project.lua @@ -51,6 +51,9 @@ local function e2_ls_project(arg) e2option.flag("all", "show unused results and sources, too") local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end info, re = e2tool.collect_project_info(info) if not info then diff --git a/local/e2-new-source.lua b/local/e2-new-source.lua index 2a4a0a9..181a323 100644 --- a/local/e2-new-source.lua +++ b/local/e2-new-source.lua @@ -223,6 +223,9 @@ local function e2_new_source(arg) e2option.option("server", "specify server") e2option.flag("no-checksum", "do not verify checksum file") local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end info, re = e2tool.collect_project_info(info) if not info then diff --git a/local/e2-playground.lua b/local/e2-playground.lua index c91c4e0..b5ad2d5 100644 --- a/local/e2-playground.lua +++ b/local/e2-playground.lua @@ -52,6 +52,10 @@ local function e2_playground(arg) e2option.flag("showpath", "prints the path of the build directory inside the chroot to stdout" ) local opts, arguments = e2option.parse(arg) + if not opts then + return false, arguments + end + -- get build mode from the command line local build_mode, re = policy.handle_commandline_options(opts, true) if not build_mode then