https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112022-10-02T14:20:45ZRuby Issue Tracking SystemRuby master - Feature #19036: Provide a way to set path for File instances created with for_fdhttps://bugs.ruby-lang.org/issues/19036?journal_id=994242022-10-02T14:20:45Zheadius (Charles Nutter)headius@headius.com
<ul></ul><p>Looking at the linked PR again I realize that we would need this functionality for IO as well, in order for the IO object to have the "masterpty" marker. The File would still need help, so we can <code>for_fd</code> but provide the slave name as path.</p> Ruby master - Feature #19036: Provide a way to set path for File instances created with for_fdhttps://bugs.ruby-lang.org/issues/19036?journal_id=1001452022-11-17T07:44:43Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Target version</strong> deleted (<del><i>3.2</i></del>)</li></ul> Ruby master - Feature #19036: Provide a way to set path for File instances created with for_fdhttps://bugs.ruby-lang.org/issues/19036?journal_id=1001462022-11-17T08:17:17Zko1 (Koichi Sasada)
<ul></ul><p>It seems okay for <code>File.for_fd(fd, path: ...)</code> but I'm not sure <code>IO.for_fd(fd, path: ...)</code>. Maybe it affects only <code>#inspect</code> because <code>IO#path</code> is not defined.</p>
<p>I think this functionality is also useful to label known IO such as:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">p</span> <span class="no">STDERR</span>
<span class="c1">#=> #<IO:<STDERR>></span>
<span class="nb">p</span> <span class="no">IO</span><span class="p">.</span><span class="nf">for_fd</span><span class="p">(</span><span class="no">STDERR</span><span class="p">.</span><span class="nf">to_i</span><span class="p">)</span>
<span class="c1">#<IO:fd 2></span>
<span class="nb">p</span> <span class="no">IO</span><span class="p">.</span><span class="nf">for_fd</span><span class="p">(</span><span class="no">STDERR</span><span class="p">.</span><span class="nf">to_i</span><span class="p">,</span> <span class="ss">path: </span><span class="s1">'<STDERR>'</span><span class="p">)</span>
<span class="c1">#=> #<IO:<STDERR>></span>
</code></pre>
<p><code>name</code> for strictly usage?</p> Ruby master - Feature #19036: Provide a way to set path for File instances created with for_fdhttps://bugs.ruby-lang.org/issues/19036?journal_id=1003822022-12-01T07:34:46Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>Ruby IO is a rich object and has an internal path. It seems reasonable that <code>IO.new</code> or <code>IO.for_fd</code> can set it. I don't think this is something specific to <code>File</code> in the way Ruby thinks about IO.</p> Ruby master - Feature #19036: Provide a way to set path for File instances created with for_fdhttps://bugs.ruby-lang.org/issues/19036?journal_id=1003932022-12-01T08:33:26Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>LGTM.</p>
<p>Matz.</p> Ruby master - Feature #19036: Provide a way to set path for File instances created with for_fdhttps://bugs.ruby-lang.org/issues/19036?journal_id=1005272022-12-08T05:22:23Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Implemented in <a href="https://github.com/ruby/ruby/pull/6867" class="external">https://github.com/ruby/ruby/pull/6867</a>.</p>
<p>Follow up discussion:</p>
<ul>
<li>Should we introduce <code>IO#path=</code>?</li>
<li>Should we introduce <code>IO#dup(..., path:)</code>?</li>
</ul> Ruby master - Feature #19036: Provide a way to set path for File instances created with for_fdhttps://bugs.ruby-lang.org/issues/19036?journal_id=1005322022-12-08T14:24:00ZEregon (Benoit Daloze)
<ul></ul><p>ioquatix (Samuel Williams) wrote in <a href="#note-6">#note-6</a>:</p>
<blockquote>
<p>Implemented in <a href="https://github.com/ruby/ruby/pull/6867" class="external">https://github.com/ruby/ruby/pull/6867</a>.</p>
</blockquote>
<p>Thanks!</p>
<blockquote>
<p>Follow up discussion:</p>
<ul>
<li>Should we introduce <code>IO#path=</code>?</li>
</ul>
</blockquote>
<p>I think not, AFAIK there is no need for this to be mutable.</p>
<blockquote>
<ul>
<li>Should we introduce <code>IO#dup(..., path:)</code>?</li>
</ul>
</blockquote>
<p>Definitely not worth the complexity, and <code>dup</code> doesn't have this general contract anyway.</p> Ruby master - Feature #19036: Provide a way to set path for File instances created with for_fdhttps://bugs.ruby-lang.org/issues/19036?journal_id=1005352022-12-09T08:50:34Zheadius (Charles Nutter)headius@headius.com
<ul></ul><p>Eregon (Benoit Daloze) wrote in <a href="#note-7">#note-7</a>:</p>
<blockquote>
<blockquote>
<ul>
<li>Should we introduce <code>IO#path=</code>?</li>
</ul>
</blockquote>
<p>I think not, AFAIK there is no need for this to be mutable.</p>
</blockquote>
<p>Agree. Also briefly brainstormed some possible security issues with being able to mutate the path after init. Don't want to go there and don't really see a need.</p>
<blockquote>
<blockquote>
<ul>
<li>Should we introduce <code>IO#dup(..., path:)</code>?</li>
</ul>
</blockquote>
<p>Definitely not worth the complexity, and <code>dup</code> doesn't have this general contract anyway.</p>
</blockquote>
<p>Agree.</p>
<p>Additional question: why is rb_io_path not part of the public C API? Luckily, rb_file_path wasn't either, but it seems like it would be useful to expose rb_io_path now.</p>