diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-02-25 11:57:42 +0100 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-02-25 11:57:42 +0100 |
commit | 0432bdf19eb3483e109582832a36dc7a3601a384 (patch) | |
tree | b238509c11cfb5e43e419d2b35a2404d8f49a95f /lib/gitlab/popen.rb | |
parent | 9f20580ed7338e72ffeadff86c0d605a2802c957 (diff) | |
download | gitlab-ce-0432bdf19eb3483e109582832a36dc7a3601a384.tar.gz |
Change Gitlab::Popen to use arrays for commands
Diffstat (limited to 'lib/gitlab/popen.rb')
-rw-r--r-- | lib/gitlab/popen.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb index 5283cf0b821..d10269f4438 100644 --- a/lib/gitlab/popen.rb +++ b/lib/gitlab/popen.rb @@ -1,8 +1,13 @@ require 'fileutils' +require 'open3' module Gitlab module Popen def popen(cmd, path) + unless cmd.is_a?(Array) + raise "System commands must be given as an array of strings" + end + vars = { "PWD" => path } options = { chdir: path } @@ -12,10 +17,10 @@ module Gitlab @cmd_output = "" @cmd_status = 0 - Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr| - @cmd_status = wait_thr.value.exitstatus + Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr| @cmd_output << stdout.read @cmd_output << stderr.read + @cmd_status = wait_thr.value.exitstatus end return @cmd_output, @cmd_status |