From: mame@... Date: 2018-04-19T15:54:47+00:00 Subject: [ruby-core:86614] [CommonRuby Feature#8258] Dir#escape_glob Issue #8258 has been updated by mame (Yusuke Endoh). Eregon (Benoit Daloze) wrote: > Looks to me like this can be closed since we have Dir.glob(pattern, base: dir) and Pathname#glob uses it. Consider that we want to enumerate all files that are under a specified directory and whose name is also specified. If the name in question is "foo.txt" for example, we can do it by: ``` basedir = "/path/to/base/dir/" filename = "foo.txt" Dir.glob(basedir + "**/" + filename) # or Dir.glob("**/" + filename, base: basedir)? ``` However, if `filename` is "foo[bar]baz.txt", this code does not work. In this case, this feature is still useful. (I personally prefer `File.fnmatch_escape` to `Dir.escape_glob`.) ---------------------------------------- Feature #8258: Dir#escape_glob https://bugs.ruby-lang.org/issues/8258#change-71572 * Author: steveklabnik (Steve Klabnik) * Status: Feedback * Priority: Normal * Assignee: * 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. -- https://bugs.ruby-lang.org/ Unsubscribe: