On 22/10/26 at 19:37, Jeffrey Walton wrote:
> On Wed, Oct 21, 2026 at 12:34 PM Franco Martelli <mart…@gmail.com> wrote:
>>
>> Hi,
>>
>> I run into issue trying to populate an array with unique random value,
>> the issue is that I have an endless loop, here the snippet:
>>
>> ...
>> # Populate playlist array with unique random values
>> while [ "$index" -le "$total" ]; do
>> clip="$(/usr/bin/numrandom /1..$total/)"
>> if [[ ! ${playlist[@]} =~ "$clip" ]]; then # [ -z
>> ${rndarr[clip]} ]; then
>> # rndarr[$clip]=1
>> playlist[$index]=$clip
>> ((index++))
>> fi
>> done
>> ...
>
> The code is broken:
>
> $ shellcheck test.sh
>
> In test.sh line 2:
> while [ "$index" -le "$total" ]; do
> ^-- SC1009 (info): The mentioned syntax error was in this while loop.
>
> In test.sh line 4:
> if [[ ! ${playlist[@]} =~ "$clip" ]]; then # [ -z
> ^-- SC1046 (error): Couldn't find 'fi' for this 'if'.
> ^-- SC1073 (error): Couldn't parse this if expression. Fix to allow mor
> e checks.
>
>
> In test.sh line 5:
> ${rndarr[clip]} ]; then
> ^-- SC1047 (error): Expected 'fi' matching previously mention
> ed 'if'.
> ^-- SC1072 (error): Unexpected keyword/token. Fix any men
> tioned problems and try again.
>
> Perhaps you can supply a working example?
already clarified, maybe a matching issue in the "if [[ ! ${playlist[@]} =~ "$clip" ]]; then" statement, please see "Second note:" in the following email:
https://lists.debian.org/debian-user/2026/10/msg00376.html
Kind regards,
--
Franco Martelli