aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-05-07 13:52:08 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-05-22 19:50:40 +0300
commit26ea986b8322dc3bd1e82cf6d819082c57a69024 (patch)
tree59620086c74d2b481aae4fefcf25e9e7bceba841 /src
parent43c1a5925baf3e4003ca4bf070910b6615f5f829 (diff)
downloadluarocks-26ea986b8322dc3bd1e82cf6d819082c57a69024.tar.gz
luarocks-26ea986b8322dc3bd1e82cf6d819082c57a69024.tar.bz2
luarocks-26ea986b8322dc3bd1e82cf6d819082c57a69024.zip
Add fs.quiet_stderr function
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/fs/unix.lua7
-rw-r--r--src/luarocks/fs/unix/tools.lua6
-rw-r--r--src/luarocks/fs/win32.lua7
-rw-r--r--src/luarocks/fs/win32/tools.lua6
4 files changed, 20 insertions, 6 deletions
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua
index e2cc825b..520b3e99 100644
--- a/src/luarocks/fs/unix.lua
+++ b/src/luarocks/fs/unix.lua
@@ -16,6 +16,13 @@ function unix.quiet(cmd)
16 return cmd.." 1> /dev/null 2> /dev/null" 16 return cmd.." 1> /dev/null 2> /dev/null"
17end 17end
18 18
19--- Annotate command string for execution with quiet stderr.
20-- @param cmd string: A command-line string.
21-- @return string: The command-line, with stderr silencing annotation.
22function unix.quiet_stderr(cmd)
23 return cmd.." 2> /dev/null"
24end
25
19--- Return an absolute pathname from a potentially relative one. 26--- Return an absolute pathname from a potentially relative one.
20-- @param pathname string: pathname to convert. 27-- @param pathname string: pathname to convert.
21-- @param relative_to string or nil: path to prepend when making 28-- @param relative_to string or nil: path to prepend when making
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua
index ab55897e..d75d9795 100644
--- a/src/luarocks/fs/unix/tools.lua
+++ b/src/luarocks/fs/unix/tools.lua
@@ -21,7 +21,7 @@ end
21function tools.current_dir() 21function tools.current_dir()
22 local current = cfg.cache_pwd 22 local current = cfg.cache_pwd
23 if not current then 23 if not current then
24 local pipe = io.popen(fs.Q(vars.PWD).." 2> /dev/null") 24 local pipe = io.popen(fs.quiet_stderr(fs.Q(vars.PWD)))
25 current = pipe:read("*l") 25 current = pipe:read("*l")
26 pipe:close() 26 pipe:close()
27 cfg.cache_pwd = current 27 cfg.cache_pwd = current
@@ -183,7 +183,7 @@ function tools.find(at)
183 return {} 183 return {}
184 end 184 end
185 local result = {} 185 local result = {}
186 local pipe = io.popen(command_at(at, vars.FIND.." * 2>/dev/null")) 186 local pipe = io.popen(command_at(at, fs.quiet_stderr(vars.FIND.." *")))
187 for file in pipe:lines() do 187 for file in pipe:lines() do
188 table.insert(result, file) 188 table.insert(result, file)
189 end 189 end
@@ -268,7 +268,7 @@ function tools.use_downloader(url, filename, cache)
268 if cfg.connection_timeout and cfg.connection_timeout > 0 then 268 if cfg.connection_timeout and cfg.connection_timeout > 0 then
269 curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " 269 curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." "
270 end 270 end
271 ok = fs.execute_string(curl_cmd..fs.Q(url).." 2> /dev/null 1> "..fs.Q(filename)) 271 ok = fs.execute_string(fs.quiet_stderr(curl_cmd..fs.Q(url).." > "..fs.Q(filename)))
272 end 272 end
273 if ok then 273 if ok then
274 return true, filename 274 return true, filename
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua
index c14c421b..74f3ed69 100644
--- a/src/luarocks/fs/win32.lua
+++ b/src/luarocks/fs/win32.lua
@@ -27,6 +27,13 @@ function win32.quiet(cmd)
27 return cmd.." 2> NUL 1> NUL" 27 return cmd.." 2> NUL 1> NUL"
28end 28end
29 29
30--- Annotate command string for execution with quiet stderr.
31-- @param cmd string: A command-line string.
32-- @return string: The command-line, with stderr silencing annotation.
33function win32.quiet_stderr(cmd)
34 return cmd.." 2> NUL"
35end
36
30local drive_letter = "[%.a-zA-Z]?:?[\\/]" 37local drive_letter = "[%.a-zA-Z]?:?[\\/]"
31 38
32local win_escape_chars = { 39local win_escape_chars = {
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua
index b9dce85c..39aa4ba1 100644
--- a/src/luarocks/fs/win32/tools.lua
+++ b/src/luarocks/fs/win32/tools.lua
@@ -39,7 +39,7 @@ end
39function tools.current_dir() 39function tools.current_dir()
40 local current = cfg.cache_pwd 40 local current = cfg.cache_pwd
41 if not current then 41 if not current then
42 local pipe = io.popen(fs.Q(vars.PWD).. " 2> NUL") 42 local pipe = io.popen(fs.quiet_stderr(fs.Q(vars.PWD)))
43 current = pipe:read("*l") 43 current = pipe:read("*l")
44 pipe:close() 44 pipe:close()
45 cfg.cache_pwd = current 45 cfg.cache_pwd = current
@@ -196,7 +196,7 @@ function tools.find(at)
196 return {} 196 return {}
197 end 197 end
198 local result = {} 198 local result = {}
199 local pipe = io.popen(command_at(at, fs.Q(vars.FIND).." 2> NUL")) 199 local pipe = io.popen(command_at(at, fs.quiet_stderr(fs.Q(vars.FIND))))
200 for file in pipe:lines() do 200 for file in pipe:lines() do
201 -- Windows find is a bit different 201 -- Windows find is a bit different
202 local first_two = file:sub(1,2) 202 local first_two = file:sub(1,2)
@@ -278,7 +278,7 @@ function tools.use_downloader(url, filename, cache)
278 if cfg.connection_timeout and cfg.connection_timeout > 0 then 278 if cfg.connection_timeout and cfg.connection_timeout > 0 then
279 curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " 279 curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." "
280 end 280 end
281 ok = fs.execute_string(curl_cmd..fs.Q(url).." 2> NUL 1> "..fs.Q(filename)) 281 ok = fs.execute_string(fs.quiet_stderr(curl_cmd..fs.Q(url).." > "..fs.Q(filename)))
282 end 282 end
283 if ok then 283 if ok then
284 return true, filename 284 return true, filename