https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112018-12-01T15:51:05ZRuby Issue Tracking SystemRuby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753332018-12-01T15:51:05ZHanmac (Hans Mackowiak)hanmac@gmx.de
<ul></ul><p>i don't think that works that easy because it depends on the filesystem which depends on the location of the file.</p>
<p>For example it might be that it's case insensitive in one location and sensitive on another.</p> Ruby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753352018-12-01T16:27:11Zahorek (Pavel Rosický)
<ul></ul><p>it looks like Ruby checks only a platform for the case-(in)sensivity</p>
<p>for example on WSL I can create a file in my home folder which is case-sensitive</p>
<pre><code>touch aAa.txt
touch aaa.txt
</code></pre>
<p>this creates two separate files</p>
<p>if I do the same in /mnt/c/* which is a remote case-insensitive NTFS filesystem. It creates only one.</p>
<p>on Windows</p>
<pre><code>irb(main):002:0> Dir['c:/aaa.txt']
=> ["c:/aAa.txt"]
</code></pre>
<p>on WSL</p>
<pre><code>irb(main):002:0> Dir['/mnt/c/aaa.txt']
=> [] (wrong)
irb(main):002:0> Dir['/mnt/c/aAa.txt']
=> ['/mnt/c/aAa.txt']
</code></pre>
<p>note that Ruby has a significant perf impact on case-insensitive filesystem already. In order to support this feature, Ruby would have to check filesystem capabilities on the fly and on every single FS operation that matters. For that reason I don't care much about fixing it.</p> Ruby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753362018-12-01T16:36:23ZMSP-Greg (Greg L)
<ul></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/11888">@ahorek (Pavel Rosický)</a> & Hans,</p>
<p>Thanks for the feedback. Both of you are right, there isn't a trivial solution to this.</p>
<p>Ok to close. The code had an error in it also...</p> Ruby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753372018-12-01T16:41:05Zahorek (Pavel Rosický)
<ul></ul><p>unlike ruby, shell's glob finds a file, but it doesn't return a real filename as a result.</p>
<pre><code>ls /mnt/c/aaa.txt
=> /mnt/c/aaa.txt (wrong)
ls /mnt/c/aAa.txt
=> /mnt/c/aAa.txt
</code></pre>
<p><a href="https://ruby-doc.org/core-2.5.0/Dir.html" class="external">https://ruby-doc.org/core-2.5.0/Dir.html</a><br>
Note that the pattern is not a regexp, it's closer to a shell glob. See File.fnmatch for the meaning of the flags parameter. Case sensitivity depends on your system (File::FNM_CASEFOLD is ignored), as does the order in which the results are returned.</p> Ruby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753432018-12-02T12:37:24Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Case-sensitiveness is runtime environment property, and may differ per mounted volumes.</p> Ruby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753442018-12-02T13:01:17Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Now I can't remember why <code>File::FNM_SYSCASE</code> is 0 on macOS..., maybe it can select case-sensitive filesystems.</p> Ruby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753452018-12-02T15:10:09ZMSP-Greg (Greg L)
<ul></ul><p>Now, I'm pretty much only windows, but previously the network I used had Windows, MacOS/OSX, and a few of *nix NAS devices. I vaguely recall some casing issues. Unfortunately, I can't test anything like that now.</p>
<p>Maybe the questions are:</p>
<ol>
<li>
<p>Should Ruby attempt to account for case insensitive file systems? The main issue I've come across is in comparisons using ENV variables that contain paths.</p>
</li>
<li>
<p>If #1 is yes, is that (reasonably) possible?</p>
</li>
</ol> Ruby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753502018-12-03T00:00:38Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>You can't compare path names just by case-insensitiveness, on Windows.<br>
Consider short file names.<br>
You can compare them by <code>File.identical?</code> instead, or should use <code>File.expand_path</code> before comparison at least.</p> Ruby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753592018-12-03T03:54:28ZMSP-Greg (Greg L)
<ul></ul><p>nobu (Nobuyoshi Nakada) wrote:</p>
<blockquote>
<p>You can't compare path names just by case-insensitiveness, on Windows.<br>
Consider short file names.<br>
You can compare them by <code>File.identical?</code> instead, or should use <code>File.expand_path</code> before comparison at least.</p>
</blockquote>
<p>Thank you for the mention of <code>File.indentical?</code>, as I have never noticed that method. Using <code>File.exist?</code> does correctly identify Windows as being case sensitive, but will give a false positive if, for instance, one has folders <code>/Ruby</code> and <code>/ruby</code> on a case sensitive file system. Unlikely, but possible...</p>
<p>I'm not sure about the effect of short file names. If <code>test</code> is a string, and <code>File.exist? test</code> is true, then the following should work?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">fs_case_insens</span> <span class="o">=</span>
<span class="p">(</span><span class="nb">test</span> <span class="o">!=</span> <span class="nb">test</span><span class="p">.</span><span class="nf">upcase</span> <span class="o">&&</span> <span class="no">File</span><span class="p">.</span><span class="nf">identical?</span><span class="p">(</span><span class="nb">test</span><span class="p">,</span> <span class="nb">test</span><span class="p">.</span><span class="nf">upcase</span> <span class="p">))</span> <span class="o">||</span>
<span class="p">(</span><span class="nb">test</span> <span class="o">!=</span> <span class="nb">test</span><span class="p">.</span><span class="nf">downcase</span> <span class="o">&&</span> <span class="no">File</span><span class="p">.</span><span class="nf">identical?</span><span class="p">(</span><span class="nb">test</span><span class="p">,</span> <span class="nb">test</span><span class="p">.</span><span class="nf">downcase</span><span class="p">)</span>
</code></pre> Ruby master - Feature #15363: Case insensitive file systems - add info to CONFIG or somewhere?https://redmine.ruby-lang.org/issues/15363?journal_id=753612018-12-03T04:30:19Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>MSP-Greg (Greg L) wrote:</p>
<blockquote>
<p>I'm not sure about the effect of short file names. If <code>test</code> is a string, and <code>File.exist? test</code> is true, then the following should work?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">fs_case_insens</span> <span class="o">=</span>
<span class="p">(</span><span class="nb">test</span> <span class="o">!=</span> <span class="nb">test</span><span class="p">.</span><span class="nf">upcase</span> <span class="o">&&</span> <span class="no">File</span><span class="p">.</span><span class="nf">identical?</span><span class="p">(</span><span class="nb">test</span><span class="p">,</span> <span class="nb">test</span><span class="p">.</span><span class="nf">upcase</span> <span class="p">))</span> <span class="o">||</span>
<span class="p">(</span><span class="nb">test</span> <span class="o">!=</span> <span class="nb">test</span><span class="p">.</span><span class="nf">downcase</span> <span class="o">&&</span> <span class="no">File</span><span class="p">.</span><span class="nf">identical?</span><span class="p">(</span><span class="nb">test</span><span class="p">,</span> <span class="nb">test</span><span class="p">.</span><span class="nf">downcase</span><span class="p">)</span>
</code></pre>
</blockquote>
<p>As far as <code>test</code> contains alphabets, yes, probably.<br>
Or maybe <code>File.identical?(test, test.swapcase)</code>.</p>