[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "unset x[0], a BASH bug?"
From: |
Oğuz |
Subject: |
Re: "unset x[0], a BASH bug?" |
Date: |
Thu, 6 May 2021 09:43:54 +0300 |
6 Mayıs 2021 Perşembe tarihinde Ulrich Windl <
Ulrich.Windl@rz.uni-regensburg.de> yazdı:
> Hi!
>
> Considering the example given in https://unix.stackexchange.
> com/a/648243/320598 I think it may be a bug, or an inappropriately
> documented feature.
>
> Basically:
> % x=(1 2 3)
> % echo "${#x[@]}"; echo "${x[@]}"
> 3
> 1 2 3
> % unset x[0]
> % echo "${#x[@]}"; echo "${x[@]}"
> 2
> 2 3
> % unset x[0]
> % echo "${#x[@]}"; echo "${x[@]}"
> 2
> 2 3
`unset x[0]' doesn't change indexes of other elements in `x'.
$ x=(1 2 3)
$ declare -p x
declare -a x=([0]="1" [1]="2" [2]="3")
$ unset x[0]
$ declare -p x
declare -a x=([1]="2" [2]="3")
And there is nothing in the documentation that suggests otherwise.
> % unset x[0]
> % echo "${#x[@]}"; echo "${x[@]}"
> 2
> 2 3
>
>
--
Oğuz