Skip to content

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

Closed

Description

@qjcg

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.

Activity

  1. changed the title [-]Brace expansion: Zero-Padding and Capital Letters not working[/-] [+]Brace expansion: zero-padding and capital letters not working[/+] on Nov 13, 2023
  2. mvdan commented on Nov 14, 2023

    @mvdan
    Owner

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

  3. qjcg commented on Nov 14, 2023

    @qjcg
    Author

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

  4. added a commit that references this issue on Feb 13, 2024
    bb3e036
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址