Project

General

Profile

Bug #11609

Dir.glob brace expansion possible edge case

Added by guilhermereiscampos (Guilherme Reis Campos) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:71138]

Description

I found an edge case of Dir.glob that don't work as i was expecting, and as my shell works.

It may happens on every version. I discovered it after spelunking through: ruby_brace_expand function on dir.c (https://github.com/ruby/ruby/blob/trunk/dir.c#L2030) (as you may look: if you add lots of '}' the nest variable won't get to 0 it will be less than zero, so it would not get into the if ( lbrace && rbrace) that parses the glob, that's the clue i have.).

Below, the output of the test script and a zsh glob expansion.

output:

➜  test-ruby  ruby test_dir.rb                                                                                        
expected: ["/private/var/folders/t6/bd6y26k14wb3y25xj3m2mc700000gn/T/__test_dir__20151021-45314-1u78o68/}}{}", "/private/var/folders/t6/bd6y26k14wb3y25xj3m2mc700000gn/T/__test_dir__20151021-45314-1u78o68/}}a"]
got: []
➜  test-ruby  ls /private/var/folders/t6/bd6y26k14wb3y25xj3m2mc700000gn/T/__test_dir__20151021-45314-1u78o68/}}{\{\},a}
/private/var/folders/t6/bd6y26k14wb3y25xj3m2mc700000gn/T/__test_dir__20151021-45314-1u78o68/}}a
/private/var/folders/t6/bd6y26k14wb3y25xj3m2mc700000gn/T/__test_dir__20151021-45314-1u78o68/}}{}

Files

test_dir.rb (383 Bytes) test_dir.rb guilhermereiscampos (Guilherme Reis Campos), 10/21/2015 10:05 PM

Associated revisions

Revision ff3288fe
Added by nobu (Nobuyoshi Nakada) about 4 years ago

dir.c: glob brace expansion [Fix GH-1061]

  • dir.c (ruby_brace_expand): glob brace expansion edge case fix. When there are closing braces '}' before a open brace '{' it must be ignored and considered as literal. [ruby-core:71138] [Bug #11609]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 52212
Added by nobu (Nobuyoshi Nakada) about 4 years ago

dir.c: glob brace expansion [Fix GH-1061]

  • dir.c (ruby_brace_expand): glob brace expansion edge case fix. When there are closing braces '}' before a open brace '{' it must be ignored and considered as literal. [ruby-core:71138] [Bug #11609]

Revision 52212
Added by nobu (Nobuyoshi Nakada) about 4 years ago

dir.c: glob brace expansion [Fix GH-1061]

  • dir.c (ruby_brace_expand): glob brace expansion edge case fix. When there are closing braces '}' before a open brace '{' it must be ignored and considered as literal. [ruby-core:71138] [Bug #11609]

Revision 52212
Added by nobu (Nobuyoshi Nakada) about 4 years ago

dir.c: glob brace expansion [Fix GH-1061]

  • dir.c (ruby_brace_expand): glob brace expansion edge case fix. When there are closing braces '}' before a open brace '{' it must be ignored and considered as literal. [ruby-core:71138] [Bug #11609]

Revision 52212
Added by nobu (Nobuyoshi Nakada) about 4 years ago

dir.c: glob brace expansion [Fix GH-1061]

  • dir.c (ruby_brace_expand): glob brace expansion edge case fix. When there are closing braces '}' before a open brace '{' it must be ignored and considered as literal. [ruby-core:71138] [Bug #11609]

Revision 52212
Added by nobu (Nobuyoshi Nakada) about 4 years ago

dir.c: glob brace expansion [Fix GH-1061]

  • dir.c (ruby_brace_expand): glob brace expansion edge case fix. When there are closing braces '}' before a open brace '{' it must be ignored and considered as literal. [ruby-core:71138] [Bug #11609]

History

Updated by guilhermereiscampos (Guilherme Reis Campos) about 4 years ago

  • Subject changed from Dir.glob brace expansion edge case that don't work properly to Dir.glob brace expansion possible edge case
#3

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Status changed from Open to Closed

Applied in changeset r52212.


dir.c: glob brace expansion [Fix GH-1061]

  • dir.c (ruby_brace_expand): glob brace expansion edge case fix. When there are closing braces '}' before a open brace '{' it must be ignored and considered as literal. [ruby-core:71138] [Bug #11609]

Also available in: Atom PDF