diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-23 11:46:57 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-23 11:50:00 -0700 |
commit | eb0d8ee4fd3e369e88fd77492d01b499d9550162 (patch) | |
tree | d7b4f2eb0c3242345a5cfaba73e61861811fd51d /railties | |
parent | 0382e440800740c53f43e4fcb378b38d0150b853 (diff) | |
download | rails-eb0d8ee4fd3e369e88fd77492d01b499d9550162.tar.gz rails-eb0d8ee4fd3e369e88fd77492d01b499d9550162.tar.bz2 rails-eb0d8ee4fd3e369e88fd77492d01b499d9550162.zip |
chdir before globbing so that we don't need to escape directory names.
fixes #5521
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/paths.rb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index b37421c09c..4ac3d88dc2 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -157,7 +157,25 @@ module Rails path = File.expand_path(p, @root.path) if @glob - result.concat Dir[File.join(path, @glob)].sort + if File.directory? path + result.concat expand_dir(path, @glob) + else + # FIXME: I think we can remove this branch, but I'm not sure. + # Say the filesystem has this file: + # + # /tmp/foobar + # + # and someone adds this path: + # + # /tmp/foo + # + # with a glob of "*", then this function will return + # + # /tmp/foobar + # + # We need to figure out if that is desired behavior. + result.concat expand_file(path, @glob) + end else result << path end @@ -177,6 +195,17 @@ module Rails end alias to_a expanded + + private + def expand_file(path, glob) + Dir[File.join(path, glob)].sort + end + + def expand_dir(path, glob) + Dir.chdir(path) do + Dir.glob(@glob).map { |file| File.join path, file }.sort + end + end end end end |