diff options
| author | Peter Melnichenko <mpeterval@gmail.com> | 2016-10-28 14:27:51 +0300 |
|---|---|---|
| committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-10-28 14:28:52 +0300 |
| commit | 7f67011db75e671068b7f02d5489491f512bf816 (patch) | |
| tree | 38fc9cec6117c9b164215c9020b17ce81779c9a3 /src | |
| parent | 8630a263b6c5f86d57eb0f3a49ddce163c8378c1 (diff) | |
| download | luarocks-7f67011db75e671068b7f02d5489491f512bf816.tar.gz luarocks-7f67011db75e671068b7f02d5489491f512bf816.tar.bz2 luarocks-7f67011db75e671068b7f02d5489491f512bf816.zip | |
Move Unix-specific fs.Q implementation into luarocks.fs.unix
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fs/lua.lua | 11 | ||||
| -rw-r--r-- | src/luarocks/fs/unix.lua | 9 |
2 files changed, 9 insertions, 11 deletions
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index a31cbb4e..41711eab 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
| @@ -30,17 +30,6 @@ local dir_stack = {} | |||
| 30 | 30 | ||
| 31 | local dir_separator = "/" | 31 | local dir_separator = "/" |
| 32 | 32 | ||
| 33 | --- Quote argument for shell processing. | ||
| 34 | -- Adds single quotes and escapes. | ||
| 35 | -- @param arg string: Unquoted argument. | ||
| 36 | -- @return string: Quoted argument. | ||
| 37 | function fs_lua.Q(arg) | ||
| 38 | assert(type(arg) == "string") | ||
| 39 | |||
| 40 | -- FIXME Unix-specific | ||
| 41 | return "'" .. arg:gsub("'", "'\\''") .. "'" | ||
| 42 | end | ||
| 43 | |||
| 44 | --- Test is file/dir is writable. | 33 | --- Test is file/dir is writable. |
| 45 | -- Warning: testing if a file/dir is writable does not guarantee | 34 | -- Warning: testing if a file/dir is writable does not guarantee |
| 46 | -- that it will remain writable and therefore it is no replacement | 35 | -- that it will remain writable and therefore it is no replacement |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 5c6b542c..e2bdc7b8 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
| @@ -22,6 +22,15 @@ function unix.quiet_stderr(cmd) | |||
| 22 | return cmd.." 2> /dev/null" | 22 | return cmd.." 2> /dev/null" |
| 23 | end | 23 | end |
| 24 | 24 | ||
| 25 | --- Quote argument for shell processing. | ||
| 26 | -- Adds single quotes and escapes. | ||
| 27 | -- @param arg string: Unquoted argument. | ||
| 28 | -- @return string: Quoted argument. | ||
| 29 | function unix.Q(arg) | ||
| 30 | assert(type(arg) == "string") | ||
| 31 | return "'" .. arg:gsub("'", "'\\''") .. "'" | ||
| 32 | end | ||
| 33 | |||
| 25 | --- Return an absolute pathname from a potentially relative one. | 34 | --- Return an absolute pathname from a potentially relative one. |
| 26 | -- @param pathname string: pathname to convert. | 35 | -- @param pathname string: pathname to convert. |
| 27 | -- @param relative_to string or nil: path to prepend when making | 36 | -- @param relative_to string or nil: path to prepend when making |
