yash-rs icon indicating copy to clipboard operation
yash-rs copied to clipboard

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

Open kpcyrd opened this issue 1 year ago • 1 comments

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!

kpcyrd avatar Aug 27 '24 01:08 kpcyrd

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

magicant avatar Aug 27 '24 15:08 magicant