magicant / yash-rs

Reimplementation of yash, an extended POSIX shell
65 stars 3 forks source link

UnclosedParam error for `"${source[@]}"` #410

Open kpcyrd opened 2 months ago

kpcyrd commented 2 months ago

hello, I noticed this shell script:

pkgname=sed
pkgver=4.9
source=("https://ftp.gnu.org/pub/gnu/sed/$pkgname-$pkgver.tar.xz"{,.sig})

for src in "${source[@]}"; do
  echo "$src"
done

Currently fails to parse with this error:

Error {
    cause: Syntax(
        UnclosedParam {
            opening_location: Location {
                code: Code {
                    value: RefCell {
                        value: "pkgname=sed\npkgver=4.9\nsource=(\"https://ftp.gnu.org/pub/gnu/sed/$pkgname-$pkgver.tar.xz\"{,.sig})\n\nfor src in \"${source[@]}\"; do\n",
                    },
                    start_line_number: 1,
                    source: Unknown,
                },
                range: 110..112,
            },
        },
    ),
    location: Location {
        code: Code {
            value: RefCell {
                value: "pkgname=sed\npkgver=4.9\nsource=(\"https://ftp.gnu.org/pub/gnu/sed/$pkgname-$pkgver.tar.xz\"{,.sig})\n\nfor src in \"${source[@]}\"; do\n",
            },
            start_line_number: 1,
            source: Unknown,
        },
        range: 118..119,
    },
}

I think this is due to "${source[@]}" which yash-syntax doesn't understand. When executing the script it's expected to print this output:

https://ftp.gnu.org/pub/gnu/sed/sed-4.9.tar.xz
https://ftp.gnu.org/pub/gnu/sed/sed-4.9.tar.xz.sig

Thanks for providing this library!

magicant commented 2 months ago

This syntax is not implemented yet. I intend to implement it, but am not sure exactly when.