Ph0enixKM / Amber

πŸ’Ž Amber the programming language compiled to bash
https://amber-lang.com
GNU General Public License v3.0
3.53k stars 70 forks source link

🐞 Shorthand assignment operator `+=` is not supported by Bash 2 #166

Open Ph0enixKM opened 3 weeks ago

Ph0enixKM commented 3 weeks ago

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
b1ek commented 2 weeks ago

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

Ph0enixKM commented 2 weeks ago

Nope. We could get the version in the syntax module

Ph0enixKM commented 2 weeks ago

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.