Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Weird error message when using bash or ksh form of array initialization
- X-seq: zsh-workers 25516
- From: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- To: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Subject: Re: Weird error message when using bash or ksh form of array initialization
- Date: Sun, 24 Aug 2008 18:13:49 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=NNr/3QiuM66HleLLOEOrR0G07Wg0F/+XkMtBLxjk0+g=; b=wBFA9TvgM0POmpZtzkoDvLE2IfirXsjLj+MvI2Gk0KtUSyKgxJ4LYkfUuaM6FATjHB N3UrPeyMmr7FY+8MjP47RZwu5Ag5UQ1z2Lw517feK/zrGJt0bG1wkWQySe0qCFeumELF RbZruQJt/0nByCQv5MQv1y65ymFfm46FQZuu0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=vEj8/7nia3Ip1m6xl3bx+JcaoRyZl4lzRUV7KMjvh+OVySZWbenhp96YxZQQrlxiUk xYgykh5Rcp+KCq7UyHyWBoLxcwEdEdKqPzCYBuLQm87kGgRmyAsRKOwGxCDVHRWaPTfU McC2foPJLoQ2kVqG3Sv7aJsvITFxnuV7ZRQFQ=
- In-reply-to: <6cd6de210808240905s40c8c86ch4766b711e87ffde5@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <6cd6de210808240905s40c8c86ch4766b711e87ffde5@xxxxxxxxxxxxxx>
2008/8/24 Rocky Bernstein <rocky.bernstein@xxxxxxxxx>:
> When I run this (erroneous?) program:
>
> typeset -a fd=()
> typeset -a sources
> typeset -i xx
>
> I get a weird error message:
>
> typeset:3: maximum nested function level reached
>
> Note that neither of these give an error:
>
> typeset -a fd=()
> typeset -a sources
>
> or
>
> typeset -a fd
> typeset -a sources
> typeset -i xx
>
> or
>
> typeset -a fd
> fd=()
> typeset -a sources
> typeset -i xx
>
> Somehow fd= is treated as a function which is indicated out by adding
> a request to print out fd=:
>
> typeset -a fd=()
> typeset -a sources
> typeset -i xx
> declare -f fd=
>
> Which reports:
> typeset:3: maximum nested function level reached
> 'fd=' () {
> typeset -a sources
> }
>
> Can someone explain what's going on?
>
> Since both bash and ksh allow an array initialization via the form
> used above, it increases the chance of getting this weird error
> message.
>
> Thanks.
I think you need to quote the arguments for typeset,
% typeset -a 'fd=()'
typeset: fd: can't assign initial value for array
Also,
% typeset -a fd=() {}
% which typeset
typeset () {
}
% which -- -a
-a () {
}
The whole thing probably gets interpreted as a function definition of
the form
name1 name2 name3 () { name1 foo bar }; name1
The function then ends up calling itself recursively which zsh protects
itself against by erroring out after some iterations, no idea how many.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author