From: "Eregon (Benoit Daloze)" Date: 2013-04-15T07:29:41+09:00 Subject: [ruby-core:54271] [CommonRuby - Feature #8258] Dir#escape_glob Issue #8258 has been updated by Eregon (Benoit Daloze). rkh (Konstantin Haase) wrote: > > - Rubinius does not handle escaped [, { and }. > > - JRuby does not handle escaped [ and ] > > These are implementation bugs, imo, and nothing to worry about here. But it means the problem will not be solved in the general case before a while. It must also have been problematic for some time, so I guess we are not in a hurry either. > > If I am not mistaken, escaping is as simple as: dir.gsub(/\[|\]|\*|\?|\{|\}/, '\\\\' + '\0'). > > Yes, but it shifts responsibility for keeping this up to date from the user code to the Ruby implementation, I agree there should be Dir.escape or Dir.escape_glob. > and should be flag dependent. I.e. Ruby 2.0 introduced the EXTGLOB flag. Can you give examples? If it works for every case except FNM_NOESCAPE, I think it is better to have a single simple way. ---------------------------------------- Feature #8258: Dir#escape_glob https://bugs.ruby-lang.org/issues/8258#change-38557 Author: steveklabnik (Steve Klabnik) Status: Open Priority: Normal Assignee: Category: Target version: This is inspired by https://github.com/rails/rails/issues/6010. Basically, if you do a Dir.glob in a directory whose name contains a glob character, things break. It would be nice to have a method which would escape the input so that we can Dir.glob inside of those directories. -- http://bugs.ruby-lang.org/