add Environment#shell - close #11

This commit is contained in:
josh committed 2014-06-11 14:59:31 -04:00
1 parent a1a4cc18cd
commit ae9021a505
4 files changed
+120

No files matched your search

+29
View File
@@ -349,6 +349,35 @@ module Rscons
path.sub(%r{^\^(?=[\\/])}, @build_root)
end
# Execute a command using the system shell.
#
# The shell is automatically determined but can be overridden by the SHELL
# construction variable. If the SHELL construction variable is specified,
# the flag to pass to the shell is automatically dtermined but can be
# overridden by the SHELLFLAG construction variable.
#
# @param command [String] Command to execute.
#
# @return [String] The command's standard output.
def shell(command)
shell_cmd =
if self["SHELL"]
flag = self["SHELLFLAG"] || begin
if self["SHELL"] == "cmd"
"/c"
else
"-c"
end
end
[self["SHELL"], flag]
else
Rscons.get_system_shell
end
IO.popen([*shell_cmd, command]) do |io|
io.read
end
end
private
# Expand target and source paths before invoking builders.