Closed laurenthuberdeau closed 4 months ago
See my response to https://github.com/mvdan/sh/issues/858. Bash supports more trickery than we do, and at least for now, that's an intentional limitation.
Hi!
Thanks for looking at the issue. The example in my original message is compatible with all POSIX-compliant shells, and doesn't use any Bash specific construct so I'm not sure how the issue you link to is related. Perhaps this example better demonstrates the error:
# Assign the value in the second argument ($2) in the variable named by the first argument ($1)
assign_to() {
: $(($1 = $2)) # Fails with "= must follow a name"
}
assign_to var1 12
echo "var1: $var1"
The following valid POSIX shell script fails to parse with
shfmt
:It seems to not like the variable expansion nested in an arithmetic expansion.