• Arrays in OpenBSD 7.8 's pdksh

    From Anthk NM@3:633/10 to All on Wednesday, November 05, 2025 18:01:01
    Hello. I'm using pdksh

    echo $KSH_VERSION
    @(#)PD KSH v5.2.14 99/07/13.2

    Base ksh(1) from OpenBSD 7.8

    and I'm trying to create some arrays
    with set -A (+a actually) while iterating a list under
    a while. The loop works fine,
    but the part from

    set +A links $line

    doesn't. Every $line it's fetched fine, that's
    not the issue.
    What's the proper syntax to fill an array in pdksh?
    Several versions are really distinct from each other.

    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Wednesday, November 05, 2025 21:37:57
    On 05.11.2025 19:01, Anthk NM wrote:
    Hello. I'm using pdksh

    echo $KSH_VERSION
    @(#)PD KSH v5.2.14 99/07/13.2

    Base ksh(1) from OpenBSD 7.8

    and I'm trying to create some arrays
    with set -A (+a actually) while iterating a list under
    a while. The loop works fine,
    but the part from

    set +A links $line

    doesn't. Every $line it's fetched fine, that's
    not the issue.
    What's the proper syntax to fill an array in pdksh?
    Several versions are really distinct from each other.

    I'm using original ksh, so I'm not sure about pdksh's specialities.

    The basic straightforward syntax (without using 'set' or 'typeset')
    is something like...

    line="A B C D E F G"

    # initialize array 'links' split by IFS
    links=( $line )
    printf "%s" "${links[@]}" ; echo

    # append to the previous 'links' array new elements from 'line'
    links=( "${links[@]}" $line )
    printf "%s" "${links[@]}" ; echo

    # add to the list with the += operator (if that's existing in pdksh)
    links+=( H I J )
    printf "%s" "${links[@]}" ; echo

    Try these options and see what fits best.

    If you post some more context (the loop) more appropriate solutions
    might be suggested.

    Janis


    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)