Amber icon indicating copy to clipboard operation
Amber copied to clipboard

[Bug] Shorthand assignment operator `+=` is not supported by Bash 2

Open Ph0enixKM opened this issue 1 year ago • 4 comments

We could add a flag --out-version=X in scope of this issue to determine which bash version output should be produced to keep outputted Bash be the most readable possible. By default we'd support Bash 2.

--out-version=3

arr+=("value")

--out-version=2

arr=("${arr[@]}" "value")

Also we could replace seq in range generation for Bash 3 with {a..b} syntax. Example syntax:

--out-version=3

{0..10}

--out-version=2

seq 0 10

Ph0enixKM avatar Jun 10 '24 11:06 Ph0enixKM

wouldn't that mean that we'd have to reimplement translator for each bash version? kinda seems like overkill for me

b1ek avatar Jun 11 '24 00:06 b1ek

Nope. We could get the version in the syntax module

Ph0enixKM avatar Jun 11 '24 10:06 Ph0enixKM

I can create a draft to better visualize this. Bash version 3 isn’t a different language. We could just determine if translating one syntax formula can lead to a bit different representation in resulting Bash.

Ph0enixKM avatar Jun 11 '24 12:06 Ph0enixKM

Wondering if it is better a CLI parameter or a comment in the amber file that specify the bash version to support.

Mte90 avatar Oct 02 '24 09:10 Mte90