Issue #8258 has been updated by Jack Nagel.


An official API for escaping paths would be a hugely useful feature. In Homebrew, we use Dir[], Dir.glob and Pathname.glob a lot, but little attention has been paid to properly escaping paths, and over the years we have accumulated a great deal of potentially problematic code.

Benoit Daloze wrote:
> Pathname could likely avoid this problem nicely in this situation: dir = Pathname("some_dir"); dir.glob("**/*.rb") { |file| ... }

We also use Pathname quite heavily in Homebrew and would definitely take advantage of this.

----------------------------------------
Feature #8258: Dir#escape_glob
https://bugs.ruby-lang.org/issues/8258#change-47398

* Author: 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.



-- 
https://bugs.ruby-lang.org/