diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2022-02-08 16:26:03 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2022-02-08 16:26:03 -0300 |
| commit | 99b1ba350d3c933322db541f86ee7a5f70995e30 (patch) | |
| tree | 2926e1a71ee7522215f7e876dd8495035fc8b31e | |
| parent | f226ebefb536a8fea5e93863cff0afcdad005ce9 (diff) | |
| download | luarocks-99b1ba350d3c933322db541f86ee7a5f70995e30.tar.gz luarocks-99b1ba350d3c933322db541f86ee7a5f70995e30.tar.bz2 luarocks-99b1ba350d3c933322db541f86ee7a5f70995e30.zip | |
Fix crash when --lua-version is malformed
| -rw-r--r-- | spec/cmd_spec.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/cmd.lua | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/spec/cmd_spec.lua b/spec/cmd_spec.lua index d28acdf6..fe27ab1b 100644 --- a/spec/cmd_spec.lua +++ b/spec/cmd_spec.lua | |||
| @@ -53,6 +53,11 @@ describe("LuaRocks command line #integration", function() | |||
| 53 | end) | 53 | end) |
| 54 | 54 | ||
| 55 | describe("--lua-version", function() | 55 | describe("--lua-version", function() |
| 56 | it("fails if given something that is not a number", function() | ||
| 57 | local output = run.luarocks("--lua-version=bozo") | ||
| 58 | assert.match("malformed", output, 1, true) | ||
| 59 | end) | ||
| 60 | |||
| 56 | it("warns but continues if given an invalid version", function() | 61 | it("warns but continues if given an invalid version", function() |
| 57 | local output = run.luarocks("--lua-version=1.0") | 62 | local output = run.luarocks("--lua-version=1.0") |
| 58 | assert.match("Warning: Lua 1.0 interpreter not found", output, 1, true) | 63 | assert.match("Warning: Lua 1.0 interpreter not found", output, 1, true) |
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 233bb1bd..962d9256 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
| @@ -463,6 +463,7 @@ Enabling completion for Fish: | |||
| 463 | :argname("<prefix>") | 463 | :argname("<prefix>") |
| 464 | parser:option("--lua-version", "Which Lua version to use.") | 464 | parser:option("--lua-version", "Which Lua version to use.") |
| 465 | :argname("<ver>") | 465 | :argname("<ver>") |
| 466 | :convert(function(s) return (s:match("^%d+%.%d+$")) end) | ||
| 466 | parser:option("--tree", "Which tree to operate on.") | 467 | parser:option("--tree", "Which tree to operate on.") |
| 467 | :hidden_name("--to") | 468 | :hidden_name("--to") |
| 468 | parser:flag("--local", "Use the tree in the user's home directory.\n".. | 469 | parser:flag("--local", "Use the tree in the user's home directory.\n".. |
