Changeset

7894:217412da818f

migrator: Fix argument parsing
author Kim Alvefur <zash@zash.se>
date Wed, 15 Feb 2017 15:30:19 +0100
parents 7893:432f721b0fdf
children 7895:1e1c18012048
files tools/migration/prosody-migrator.lua
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/tools/migration/prosody-migrator.lua	Wed Feb 15 15:29:37 2017 +0100
+++ b/tools/migration/prosody-migrator.lua	Wed Feb 15 15:30:19 2017 +0100
@@ -16,19 +16,18 @@
 
 -- Command-line parsing
 local options = {};
-local handled_opts = 0;
-for i = 1, #arg do
+local i = 1;
+while arg[i] do
 	if arg[i]:sub(1,2) == "--" then
 		local opt, val = arg[i]:match("([%w-]+)=?(.*)");
 		if opt then
 			options[(opt:sub(3):gsub("%-", "_"))] = #val > 0 and val or true;
 		end
-		handled_opts = i;
+		table.remove(arg, i);
 	else
-		break;
+		i = i + 1;
 	end
 end
-table.remove(arg, handled_opts);
 
 if CFG_SOURCEDIR then
 	package.path = CFG_SOURCEDIR.."/?.lua;"..package.path;