-
Notifications
You must be signed in to change notification settings - Fork 62
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
Braces don't expand if they start with the range operator #48
Comments
@tim-hitchins-ekkosense thanks for reporting this. That's definitely a bug. |
@jonschlinkert I'm happy to take a stab at a PR for this if it would be helpful, but I've not looked into it yet, so it may take me a while to find a fix! |
Sure, that would be great! |
Okay, used # test.sh
echo {..a,b}
echo {b,..a}
echo {a..,b}
echo {...,b}
echo {a,..,b}
echo ..{a,b}
echo {{..,..},a,b}
echo {{{..,..}a,b}c,d}
echo ..{..,{..,{..,..}a,b}c,d}
echo ..
echo {,..}
echo {..,}
echo {..,..,..}
echo {...,..,..}
echo {..,...,..}
echo {./../.,../../}
echo {../../../,../../}
echo {...,...,...}
echo {.,..,.}
echo ,{..,..,.},
echo {1..2,3..4}
echo {..2,3..4}
echo {1..,2}
echo {1..,..2..,..3}
echo ..{1..3}
echo ..{1..3}{..,..}
echo {..a,b
echo {b,..a
echo {a..,b
echo {...,b
echo {a,..,b
echo ..{a,b
echo {{..,..},a,b
echo {{{..,..}a,b}c,d
echo {{{..,..}a,bc,d}
echo ..{..,{..,{..,..}a,b}c,d
echo ..
echo {,..
echo {..,
echo {..,..,..
echo {...,..,..
echo {..,...,..
echo {./../.,../../
echo {../../../,../../
echo {...,...,...
echo {.,..,.
echo ,{..,..,.},
echo {1..2,3..4
echo {..2,3..4
echo {1..,2
echo {1..,..2..,..3
echo ..{1..3
echo ..{1..3}{..,..
echo ..a,b}
echo b,..a}
echo a..,b}
echo ...,b}
echo a,..,b}
echo ..a,b}
echo {..,..},a,b}
echo {{..,..}a,b}c,d}
echo ....,{..,{..,..}a,b}c,d}
echo ..
echo ,..}
echo ..,}
echo ..,..,..}
echo ...,..,..}
echo ..,...,..}
echo ./../.,../../}
echo ../../../,../../}
echo ...,...,...}
echo .,..,.}
echo ,..,..,.},
echo 1..2,3..4}
echo ..2,3..4}
echo 1..,2}
echo 1..,..2..,..3}
echo ..1..3}
echo ..1..3}{..,..} and then ./test.sh | sed "s/ /', '/g" | xargs -d$"\n" printf "['%s']\n" to assess a load of test cases and generate the expected results. Aside, I don't know if this is something you'd want, but because this library is a) aiming to copy bash (almost - I think you support spaces in braces) and b) it's a constrained character set, it's a good case for some fuzz testing. import random
alphabet = ['a', 'b', 'c', '1', '2', '3', '{', '}', '.', ',']
for i in range (int(1e2)):
string = ''
for i in range (random.randint(3, 25)):
string += random.choice(alphabet)
print (string) and then run with the very ugly python3 test.py | xargs -d$"\n" -I % bash -c "echo -n \"%|\"; echo %" | sed "s/ /', '/g" | sed "s/|/', {}, ['/" | xargs -d$"\n" printf "['%s']]\n" for some output like ['3b{33abbb,b1ba,c{{,3}', {}, ['3b{33abbb,b1ba,c{', '3b{33abbb,b1ba,c{3']]
['3.c,,c{bc2}cc', {}, ['3.c,,c{bc2}cc']]
['b}c22.b{b,2,{12aaa3cc3c', {}, ['b}c22.b{b,2,{12aaa3cc3c']]
['11}..122', {}, ['11}..122']]
['2c{', {}, ['2c{']]
['}bc22b{3a{3a22a3..', {}, ['}bc22b{3a{3a22a3..']]
['}1,{ca{,{{,}.c1c321,a1}1', {}, ['}1,{ca{,.c1c3211', '}1,{ca{,.c1c3211', '}1,{ca{,a11']]
['c2b3b2b}c,,.}23b12,a,b}11', {}, ['c2b3b2b}c,,.}23b12,a,b}11']] to give a load of test cases. Add Let me know if you'd like this sort of thing added (in another task). |
Anyway, @jonschlinkert - PR raised. |
Example:
Expected result:
Actual result:
Note that the current behaviour is differing from the bash implementation:
Note that it does work if the .. comes anywhere except the first parameter to the brace, so
do each give
The text was updated successfully, but these errors were encountered: