Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: issues with ${array[x][y]}
- X-seq: zsh-workers 42427
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: issues with ${array[x][y]}
- Date: Tue, 6 Mar 2018 09:02:31 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=dzszmeMcm48n26oJZbPWI6rtrcl4V7SJEfu4F7h8lgE=; b=ulYil1ezXnPVTNCDgtiMXsTqaPPuShv9N9Gy8D5oVFH0z2BaJArgL2RHYagh3LywzO li7YQjyooW5bojvxjM/onaE4AtdU6sKMnyxAFrbBZTTs9fuwWk29EWGu6h6BagG/Iypm caqe86KDtX5/dVVqE7KzDh3aAhTJP871JcUxL/msJOYKnNuA/ifthDZpITK/vObzVFOa j5aGrGWbA/nPt6wWuLinb5QfBTcN4XJos1Y3XnTPiIX7lIZCvu1RZVfXo+pCHnJ067+s hvFNuq6SWr8ouvLB9RcsT+alxWSDKzViTM+TfAm1qAE9Sf3Q2ckq3PGRhBUTfY4H6a4Y oIeg==
- In-reply-to: <20180306151644.GA10296@chaz.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180306151644.GA10296@chaz.gmail.com>
On Mar 6, 3:16pm, Stephane Chazelas wrote:
} Subject: issues with ${array[x][y]}
}
} $ a=(foo bar)
} $ x='a[1][1]'
} $ echo ${(P)x}
} foo
This is happening because ${{(P)var}[1]} must treat ${(P)var} as an array
any time the name referred to by $var is an array, so array-ness is being
preserved when doing the first a[1] dereference.
} There's also a consistency issue in that one can do:
}
} string[1]=x
}
} and reference ${array[1][1]}
}
} but:
}
} $ a[1][1]=b
} zsh: no matches found: a[1][1]=b
Having ${array[1][1]} is mostly for convenience, because it dates from
before ${${array[1]}[1]} would have been syntactically valid. It was
never intended to work as an assignment.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author