Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brace expansion: zero-padding and capital letters not working #1042

Closed
qjcg opened this issue Nov 13, 2023 · 2 comments
Closed

Brace expansion: zero-padding and capital letters not working #1042

qjcg opened this issue Nov 13, 2023 · 2 comments

Comments

@qjcg
Copy link

qjcg commented Nov 13, 2023

Hello,

First of all, thanks for the truly excellent library!

I noticed a couple of brace expansions that don't work with this library, but do work in bash, and wanted to flag them here, since I find them quite useful and believe others may as well:

  1. Sequence expressions don't allow zero-padding
  2. Sequence expressions don't work with capital letters

Examples:

expression bash result library result
test{01..03} test01 test02 test03 test1 test2 test3
test{01..3} test01 test02 test03 test1 test2 test3
test{1..03} test01 test02 test03 test1 test2 test3
test{000..100..50} test000 test050 test100 test0 test50 test100
test{A..C} testA testB testC test{A..C}

Here's what's described in bash(1)/Brace Expansion:

[...]

A sequence expression takes the form {x..y[..incr]}, where x and y are either integers or letters, and incr, an optional increment, is an integer. When integers are supplied, the expression expands to each number between x and y, inclusive. Supplied integers may be prefixed with ‘0’ to force each term to have the same width. When either x or y begins with a zero, the shell attempts to force all generated terms to contain the same number of digits, zero-padding where necessary. When letters are supplied, the expression expands to each character lexicographically between x and y, inclusive, using the default C locale. Note that both x and y must be of the same type (integer or letter). When the increment is supplied, it is used as the difference between each term. The default increment is 1 or -1 as appropriate.

@qjcg qjcg changed the title Brace expansion: Zero-Padding and Capital Letters not working Brace expansion: zero-padding and capital letters not working Nov 13, 2023
@mvdan
Copy link
Owner

mvdan commented Nov 14, 2023

Hi, thanks for spotting these! They look like minor oversights in our implementation.

mvdan added a commit that referenced this issue Nov 14, 2023
They clearly work in Bash:

    $ echo test{A..C}
    testA testB testC

Updates #1042.
@mvdan mvdan closed this as completed in bb3e036 Nov 14, 2023
@qjcg
Copy link
Author

qjcg commented Nov 14, 2023

Awesome, thanks for the extremely quick updates @mvdan, hugely appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants