Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: set -A
- X-seq: zsh-users 5886
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: set -A
- Date: Fri, 7 Feb 2003 03:53:14 +0000
- In-reply-to: <20030207000138.GK5418@xxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20030207000138.GK5418@xxxxxx>
On Feb 6, 7:01pm, Paul Ackersviller wrote:
} Subject: set -A
}
} unset arr
} set -A arr "${arr[@]}" first
} [ ${#arr[@]} = 2 ] && echo "arr[0]='${arr[0]}' arr[1]='${arr[1]}'"
}
} Note the null entry on the start of the array.
This really has nothing to do with "set -A".
If you've unset arr, then arr is not an array, and hence ${arr[@]} is
not an array either, and therefore "${arr[@]}" does not behave like
an array; rather, it behaves like a string, so putting it in double
quotes yields the empty string.
} I believe the above should work as in ksh, and consistently with
} positional parameters
Doesn't follow. $@ cannot be unset, it can only be set to the empty
array. This example ...
} set --
} set -A arr "$@" first
} echo arr now has only ${#arr[@]} element
... really corresponds to:
arr=()
set -A arr "${arr[@]}" first
echo arr now has only ${#arr[@]} element
} [...] it'd be nice if it at least worked like ksh in emulation mode.
This is a clash with zsh's usage where subscripts on a string yeild
substring slices. The substring slice [@] is the entire string, so
${string[@]} == ${string}. We were under the impression that this
could not possibly clash with a valid ksh script, because no working
ksh script could rely upon subscripting a string.
We may have to rethink that.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author