[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature Request: C struct-like template
From: |
pepa65 |
Subject: |
Re: Feature Request: C struct-like template |
Date: |
Thu, 14 Jan 2021 19:16:12 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 14/01/2021 16.44, William Park wrote:
> Then, I just use variable "rev" and that would be equivalent to
> ${@:55:10}.
So you could just do: rev=(${template[@]:55:10})
With a little function like this, you could call:
Struct template date 7 dev 16 ver 32 rev 10
and get what you want with an existing array 'template'.
Struct(){
local template=$1 n=0
shift
while (($2>0))
do eval "$1=(\${$template[@]:$n:$2})"
((n+=$2))
shift 2
done
}
Cheers,
Peter