diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2013-10-13 22:40:33 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-10-13 22:40:33 -0300 |
| commit | f9a24099c30c879a7d686fa5ea3f86ed2ab489b4 (patch) | |
| tree | 40eb6dd4c96e93f4df9479722550cdfe5e1d92ae /src | |
| parent | b6990a69380aed9ed718d4ca13fefab05a9811f7 (diff) | |
| download | luarocks-f9a24099c30c879a7d686fa5ea3f86ed2ab489b4.tar.gz luarocks-f9a24099c30c879a7d686fa5ea3f86ed2ab489b4.tar.bz2 luarocks-f9a24099c30c879a7d686fa5ea3f86ed2ab489b4.zip | |
Escape doublebrackets in paths that go to wrappers.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fs/unix.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/fs/win32.lua | 3 | ||||
| -rw-r--r-- | src/luarocks/util.lua | 4 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 5b9a11b5..e154ef45 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
| @@ -54,6 +54,8 @@ function wrap_script(file, dest, name, version) | |||
| 54 | local base = dir.base_name(file) | 54 | local base = dir.base_name(file) |
| 55 | local wrapname = fs.is_dir(dest) and dest.."/"..base or dest | 55 | local wrapname = fs.is_dir(dest) and dest.."/"..base or dest |
| 56 | local lpath, lcpath = cfg.package_paths() | 56 | local lpath, lcpath = cfg.package_paths() |
| 57 | lpath = util.escape_doublebrackets(lpath) | ||
| 58 | lcpath = util.escape_doublebrackets(lcpath) | ||
| 57 | local wrapper = io.open(wrapname, "w") | 59 | local wrapper = io.open(wrapname, "w") |
| 58 | if not wrapper then | 60 | if not wrapper then |
| 59 | return nil, "Could not open "..wrapname.." for writing." | 61 | return nil, "Could not open "..wrapname.." for writing." |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 8f14239d..ba3ba2b3 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
| @@ -7,6 +7,7 @@ local fs = require("luarocks.fs") | |||
| 7 | 7 | ||
| 8 | local cfg = require("luarocks.cfg") | 8 | local cfg = require("luarocks.cfg") |
| 9 | local dir = require("luarocks.dir") | 9 | local dir = require("luarocks.dir") |
| 10 | local util = require("luarocks.util") | ||
| 10 | 11 | ||
| 11 | --- Annotate command string for quiet execution. | 12 | --- Annotate command string for quiet execution. |
| 12 | -- @param cmd string: A command-line string. | 13 | -- @param cmd string: A command-line string. |
| @@ -64,6 +65,8 @@ function wrap_script(file, dest, name, version) | |||
| 64 | local wrapname = fs.is_dir(dest) and dest.."/"..base or dest | 65 | local wrapname = fs.is_dir(dest) and dest.."/"..base or dest |
| 65 | wrapname = wrapname..".bat" | 66 | wrapname = wrapname..".bat" |
| 66 | local lpath, lcpath = cfg.package_paths() | 67 | local lpath, lcpath = cfg.package_paths() |
| 68 | lpath = util.escape_doublebrackets(lpath) | ||
| 69 | lcpath = util.escape_doublebrackets(lcpath) | ||
| 67 | local wrapper = io.open(wrapname, "w") | 70 | local wrapper = io.open(wrapname, "w") |
| 68 | if not wrapper then | 71 | if not wrapper then |
| 69 | return nil, "Could not open "..wrapname.." for writing." | 72 | return nil, "Could not open "..wrapname.." for writing." |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index e3260359..cfcd2013 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
| @@ -511,3 +511,7 @@ function array_contains(tbl, value) | |||
| 511 | end | 511 | end |
| 512 | return false | 512 | return false |
| 513 | end | 513 | end |
| 514 | |||
| 515 | function escape_doublebrackets(s) | ||
| 516 | return s:gsub("(([%[%]])%2)","]]..'%1'..[[") | ||
| 517 | end \ No newline at end of file | ||
