https://www.chiliproject.org/2012-02-15T13:32:58+01:00ChiliProjectChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=144772012-02-15T13:32:58+01:00Dies Koperdiesk@fast.au.fujitsu.com
<ul><li><strong>Start date</strong> set to <i>2012-02-15</i></li><li><strong>Priority</strong> set to <i>Normal</i></li><li><strong>Project</strong> set to <i>ChiliProject</i></li><li><strong>Target version</strong> set to <i>3.1.0</i></li><li><strong>Assignee</strong> set to <i>Felix Schäfer</i></li><li><strong>Subject</strong> set to <i>quotes around path when shelling out does not work on Windows</i></li><li><strong>Category</strong> set to <i>Testing</i></li><li><strong>Tracker</strong> set to <i>Bug</i></li><li><strong>Description</strong> set to <i>I encountered the following error when running rake test on Windows 7 with CP...</i> <a href="/journals/14477/diff/description" class="lightbox-ajax">More</a></li><li><strong>Status</strong> set to <i>Open</i></li></ul> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=145152012-02-17T01:42:55+01:00Dies Koperdiesk@fast.au.fujitsu.com
<ul></ul><p>FYI, by simply removing the quotes in version.rb I was able to confirm all tests pass on Windows Server 2003 SE SP2 with pg 0.9.0 and 0.13.1.</p>
<pre>
712 tests, 2199 assertions, 0 failures, 0 errors
...
1181 tests, 2141 assertions, 0 failures, 0 errors
</pre> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=145322012-02-17T12:48:47+01:00Felix Schäferfelix+chili@oh14.de
<ul></ul><p>Just removing the quotes probably won't be enough because it will probably break as soon as there's a space in the path, but it's a good starting point. I don't know windows enough, could you see if it works if double instead of single quotes?</p> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=145672012-02-20T03:19:21+01:00Dies Koperdiesk@fast.au.fujitsu.com
<ul></ul><p>You're probably right. I've done the tests again, even renamed my CP installation directory to contain a few spaces ("d:\sources\OSS\IT\dir with spaces\chiliproject"), with double quotes and all passed.<br />I've also run the tests on CentOS with this change to confirm it didn't break anything there.</p>
<p>This is what I now have in version.rb:</p>
<pre>
git.send(:shellout, "#{git.sq_bin} --git-dir=\"#{git_dir}\" rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp
</pre>
<p>I'd push a patch but git is giving me weird errors.</p> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=148062012-02-29T23:02:06+01:00Luke Carrierluke@carrier.im
<ul></ul><p>I promise I'll actually start writing my own fixes soon...haha. Here's another patch, it's working perfectly for me on a couple of RedHat 5/6 boxes:</p>
<pre>
diff --git a/lib/chili_project/version.rb b/lib/chili_project/version.rb
index 8065451..894e807 100644
--- a/lib/chili_project/version.rb
+++ b/lib/chili_project/version.rb
@@ -43,7 +43,7 @@ module ChiliProject
git_dir = Rails.root.join('.git')
if File.directory? git_dir
- git.send(:shellout, "#{git.sq_bin} --git-dir='#{git_dir}' rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp
+ git.send(:shellout, "#{git.sq_bin} --git-dir=\"#{git_dir}\" rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp
end
end
end
</pre> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=148092012-02-29T23:43:17+01:00Felix Schäferfelix+chili@oh14.de
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>As this shouldn't change anything on unixes and has been confirmed by Dies to work on Windows, committed in <a href="https://www.chiliproject.org/projects/chiliproject/repository/revisions/4b5271f48750ad73d5b7395b09b049ab50c090a6" class="changeset" title="Correct quotation #891 The Windows shell doesn't seem to support single quotes… Contribut...">4b5271f</a>, thanks to you both!</p>
<p>Luke: I don't care much whose problems you tackle, even going through the "low-hanging" issues and confirming/consolidating fixes is a huge help, thanks :-)</p> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=148372012-03-01T03:45:39+01:00Toshi MARUYAMA
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li></ul><p>This commit cannot work on Linux path with double-quote.</p>
<pre>
$ pwd
/REDMINE/WORK-DIR-NO-RAID/git-workdir/chili"project
$ LC_ALL=C ruby script/server -e test -p 7000
=> Booting WEBrick
=> Rails 2.3.14 application starting on http://0.0.0.0:7000
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /home/moriya/.rvm/gems/ruby-1.8.7-p357/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21.
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-03-01 12:43:33] INFO WEBrick 1.3.1
[2012-03-01 12:43:33] INFO ruby 1.8.7 (2011-12-28) [i686-linux]
[2012-03-01 12:43:33] INFO WEBrick::HTTPServer#start: pid=7262 port=7000
</pre> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=148422012-03-01T07:55:25+01:00Felix Schäferfelix+chili@oh14.de
<ul></ul><p>Toshi MARUYAMA wrote:</p>
<blockquote>
<p>This commit cannot work on Linux path with double-quote.</p>
</blockquote>
<p>Indeed, but it wouldn't have worked with a single-quote in the path before that either :-)</p>
<p>Thanks for noticing and reporting, I'll see about that before the next release.</p> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=148672012-03-01T21:05:05+01:00Luke Carrierluke@carrier.im
<ul></ul><p>Perhaps something like this instead?</p>
<pre>
diff --git a/lib/chili_project/version.rb b/lib/chili_project/version.rb
index 8065451..894e807 100644
--- a/lib/chili_project/version.rb
+++ b/lib/chili_project/version.rb
@@ -43,7 +43,7 @@ module ChiliProject
git_dir = Rails.root.join('.git')
if File.directory? git_dir
- git.send(:shellout, "#{git.sq_bin} --git-dir='#{git_dir}' rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp
+ git.send(:shellout, "#{git.sq_bin} --git-dir=\"#{git_dir.gsub(/["]/, "\\\\\"")}\" rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp
end
end
end
</pre> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=148712012-03-01T23:40:19+01:00Felix Schäferfelix+chili@oh14.de
<ul><li><strong>Category</strong> deleted (<strike><i>Testing</i></strike>)</li></ul><p>Luke Carrier wrote:</p>
<blockquote>
<p>Perhaps something like this instead?</p>
</blockquote>
<p>Like this yes, exactly that probably won't work as (if memory serves) you'd be calling <code>gsub</code> on a <code>Pathname</code>, <code>Pathname#gsub</code> is a private method though.</p>
<p>I think the best approach is to just use the <code>shell_quote</code> method available from the SCM adapters, i.e. <code>git.shell_quote "string"</code> in this case.</p> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=148722012-03-01T23:50:50+01:00Felix Schäferfelix+chili@oh14.de
<ul></ul><p>OK, this works on OS X with <code>"</code> and <code>'</code> in the path, Dies (or anyone else), could you try this patch (against current master) on windows?</p>
<pre><code class="diff syntaxhl"><span class="CodeRay"><span class="line-numbers"> 1</span><span class="line comment">diff --git a/lib/chili_project/version.rb b/lib/chili_project/version.rb</span>
<span class="line-numbers"> 2</span><span class="line comment">index 894e807..2afb5a4 100644</span>
<span class="line-numbers"> 3</span><span class="line head"><span class="head">--- </span><span class="filename">a/lib/chili_project/version.rb</span></span>
<span class="line-numbers"> 4</span><span class="line head"><span class="head">+++ </span><span class="filename">b/lib/chili_project/version.rb</span></span>
<span class="line-numbers"> 5</span><span class="change"><span class="change">@@</span> -43,7 +43,7 <span class="change">@@</span></span> <span class="keyword">module</span> <span class="class">ChiliProject</span>
<span class="line-numbers"> 6</span> git_dir = <span class="constant">Rails</span>.root.join(<span class="string"><span class="delimiter">'</span><span class="content">.git</span><span class="delimiter">'</span></span>)
<span class="line-numbers"> 7</span>
<span class="line-numbers"> 8</span> <span class="keyword">if</span> <span class="constant">File</span>.directory? git_dir
<span class="line-numbers"> 9</span><span class="line delete"><span class="delete">-</span> git.send(<span class="symbol">:shellout</span>, <span class="string"><span class="delimiter">"</span><span class="inline"><span class="inline-delimiter">#{</span>git.sq_bin<span class="inline-delimiter">}</span></span><span class="content"> --git-dir=</span></span><span class="eyecatcher"><span class="string"><span class="char">\"</span><span class="inline"><span class="inline-delimiter">#{</span>git_dir<span class="inline-delimiter">}</span></span><span class="char">\"</span></span></span><span class="string"><span class="content"> rev-parse --short=9 HEAD</span><span class="delimiter">"</span></span>) { |io| io.read }.to_s.chomp</span>
<span class="line-numbers"><strong>10</strong></span><span class="line insert"><span class="insert">+</span> git.send(<span class="symbol">:shellout</span>, <span class="string"><span class="delimiter">"</span><span class="inline"><span class="inline-delimiter">#{</span>git.sq_bin<span class="inline-delimiter">}</span></span><span class="content"> --git-dir=</span><span class="inline"></span></span><span class="eyecatcher"><span class="string"><span class="inline"><span class="inline-delimiter">#{</span>git.shell_quote git_dir.to_s<span class="inline-delimiter">}</span></span></span></span><span class="string"><span class="content"> rev-parse --short=9 HEAD</span><span class="delimiter">"</span></span>) { |io| io.read }.to_s.chomp</span>
<span class="line-numbers">11</span> <span class="keyword">end</span>
<span class="line-numbers">12</span> <span class="keyword">end</span>
<span class="line-numbers">13</span> <span class="keyword">end</span>
</span></code></pre> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=148932012-03-05T05:41:23+01:00Dies Koperdiesk@fast.au.fujitsu.com
<ul></ul><p>I have applied the patch to today's master and reran the tests on Windows 7 in a directory name with spaces. All tests passed.</p> ChiliProject - Bug #891: quotes around path when shelling out does not work on Windowshttps://www.chiliproject.org/issues/891?journal_id=149142012-03-05T17:23:38+01:00Felix Schäferfelix+chili@oh14.de
<ul><li><strong>Assignee</strong> deleted (<strike><i>Felix Schäfer</i></strike>)</li><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Dies, thanks for testing, committed in <a href="https://www.chiliproject.org/projects/chiliproject/repository/revisions/ef5dddf4dbea81908fc7849a66f56063c49138e8" class="changeset" title="Switch to GitAdapter for quoting #891 Fixes problems with paths containing quotes (sic)">ef5dddf</a>.</p>