Project

General

Profile

Actions

Feature #16790

open

string format and refinements

Feature #16790: string format and refinements

Added by dsisnero (Dominic Sisneros) over 5 years ago. Updated over 5 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:97901]

Description

I did:

require 'pathname' module PathRefinement refine Pathname do def to_s '"%s"' % self end end end module Builder using PathRefinement def call(s,params) cmd = s % params puts cmd system(cmd) end module_function :call end file = Pathname($0).expand_path Builder.call("cat %s", file) 

I got:

C:\Users\Dominic E Sisneros\source\repos\ruby\refine_pathname>ruby system_refinement.rb cat C:/Users/Dominic E Sisneros/source/repos/ruby/refine_pathname/system_refinement.rb cat: 'C:/Users/Dominic': No such file or directory cat: E: No such file or directory cat: Sisneros/source/repos/ruby/refine_pathname/system_refinement.rb: No such file or directory 

I expected:

cat \"C:/Users/Dominic E Sisneros/source/repos/ruby/refine_pathname/system_refinement.rb\" 

because format %s is supposed to call to_s.

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago Actions #1 [ruby-core:97902]

  • Tracker changed from Bug to Feature
  • Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN)

This isn't a bug, as it is currently expected that refinements would not be used in this case. Switching this to a feature request.

Updated by sawa (Tsuyoshi Sawada) over 5 years ago Actions #2

  • Description updated (diff)
Actions

Also available in: PDF Atom