Open riacataquian opened 2 years ago
This is similar to https://github.com/mvdan/sh/issues/743, but applied to arithmetic expressions rather than assignment expressions.
I think it makes sense to do this kind of "second pass parsing", where we do an arithmetic expression parse on the expanded string field while interpreting. We can't pretend to only support parsing statically, because then we lose too much compatibility with sh/bash, as you point out.
I think my only worry would be the performance; we don't want to be re-parsing absolutely every string that goes through the arithmetic expression interpreter. One way would be to only do this re-parsing if a field was a quoted string.
Given
let.sh
as the input file:On bash:
Versus on gosh:
Gosh correctly evaluated
let varone=1 vartwo=++varone
but notlet myvar="16 << 2"
.