[#97678] [Ruby master Feature#16752] :private param for const_set — bughitgithub@...
Issue #16752 has been reported by bughit (bug hit).
5 messages
2020/04/02
[ruby-core:97790] [Ruby master Feature#16688] Allow #to_path object as argument to system()
From:
mame@...
Date:
2020-04-10 11:44:11 UTC
List:
ruby-core #97790
Issue #16688 has been updated by mame (Yusuke Endoh).
I'd like to confirm: `system(Pathname("cat /etc/passwd"))` should attempt to execute a file whose path is `./cat\ /etc/passwd`, not attempt to show the content of `/etc/passwd`, right?
----------------------------------------
Feature #16688: Allow #to_path object as argument to system()
https://bugs.ruby-lang.org/issues/16688#change-85007
* Author: Dan0042 (Daniel DeLorme)
* Status: Open
* Priority: Normal
----------------------------------------
I often work with Pathname objects, but when passing them to a system command I find it a bit tedious that they have to be explicitly converted to a String.
```ruby
file = BASE + "config.json"
system(@cmd, file) #=> TypeError (no implicit conversion of Pathname into String)
system(@cmd, file.to_s) #=> works
```
I propose that the system/exec/spawn family of methods should try to convert their arguments using `to_path`, if `to_str` fails. I believe it makes perfect sense, since commandline arguments are so often pathnames.
This includes in/out redirection. `system("ls", out: Pathname.new("file"))` should be valid.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>