From: shevegen@... Date: 2020-03-11T20:29:07+00:00 Subject: [ruby-core:97454] [Ruby master Feature#16688] Allow #to_path object as argument to system() Issue #16688 has been updated by shevegen (Robert A. Heiler). I do not have a strong opinion either way; I myself sort of just use Dir[] rather than Pathname (I just love Dir['*.rb'] and things like that), so I would not need pathname anyway. But I can understand the argument given - 10 years is also quite a long time ago, and the linked issue actually then refers to a commit from matz in 2004, so 16 years ago. That's a long time. I would recommend to focus primarily on #to_path rather than a #to_str, if only for the purpose of the suggestion here; and perhaps suggest it for an upcoming developer meeting, if this is wanted by Daniel, such as for https://bugs.ruby-lang.org/issues/16661. ---------------------------------------- Feature #16688: Allow #to_path object as argument to system() https://bugs.ruby-lang.org/issues/16688#change-84598 * 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: