You would be better served to parse that, and then do the loop, rather than just evaling arbitrary strings that may include Bobby Tables, or rm -rf *
I suggest a series of simple regex:
- Remove everything that is not a digit, a comma or a '..'
- clean up leading/trailing commas and multiple commas in a row
- Validate (everything should in the expected form (number {comma or EOS}, or number dot-dot number {comma or EOS})
- split on commas
- For each item in the split, capture some digits followed by an optional '..' with more captured digits afterwards
- If there wasn't a '..', then just print $1, other wise, print $_ for $1..$2