Skip to content
Browse files

bugfix in os.getopt(): "-" not recognized

  • Loading branch information...
1 parent 51bdfac commit 9aaabb7beae96156072c97aa3b2d1d85b8267097 Heng Li committed May 1, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 lua/klib.lua
View
6 lua/klib.lua
@@ -72,14 +72,16 @@ function os.getopt(args, ostr)
local arg, place = nil, 0;
return function ()
if place == 0 then -- update scanning pointer
- if #args == 0 or args[1]:sub(1, 1) ~= '-' then return nil end
+ place = 1
+ if #args == 0 or args[1]:sub(1, 1) ~= '-' then place = 0; return nil end
if #args[1] >= 2 then
+ place = place + 1
if args[1]:sub(2, 2) == '-' then -- found "--"
+ place = 0
table.remove(args, 1);
return nil;
end
end
- place = 2
end
local optopt = args[1]:sub(place, place);
place = place + 1;

0 comments on commit 9aaabb7

Please sign in to comment.
Something went wrong with that request. Please try again.