You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Unsupported ${var...} operators (${x//a/b}, ${x^^}, ${x:1:3}) silently expand to the wrong value #365
A script that sanitises a name with ${x//[^a-zA-Z0-9.]/_} or lowercases with ${x,,} carries on with the unchanged value and no sign that anything went wrong.
Additional Context
Found while reviewing #351; it is unrelated to that change and behaves the same with and without it.
In src/parser.rs, after the variable name is read:
The fallback arm at lines 574-584 handles any operator it doesn't know (/, ^, ,, @). It skips to the closing } and returns WordPart::Var(name).
The : arm at lines 531-543 returns WordPart::Var(name) for a colon that isn't followed by -, =, ? or +, without consuming the rest. That is why ${x:1:3} prints hello1:3}.
Possible Solution
Short term: report unsupported operators as an error instead of dropping them. Longer term: implement ${var/pat/rep}, ${var//pat/rep}, ${var:offset:length} and the case-conversion forms.
Related Issues
#207 (bash-isms agents write by default; these forms aren't on its list)
Activity