Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Unset and $empty[(i)] and $empty[(I)] -- worth the effort?
- X-seq: zsh-workers 47729
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Unset and $empty[(i)] and $empty[(I)] -- worth the effort?
- Date: Mon, 7 Dec 2020 15:13:24 -0800
- Archived-at: <https://zsh.org/workers/47729>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-12/CAH%2Bw%3D7aQNk4g6y2NZC0skZg%2B1RxKZH5GAXM1Gi6PUYi58Aa27g%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-ot1-f43.google.com) smtp.remote-ip=209.85.210.43; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=ToVR8FglKjQKviXoin46fLrJgna/ykBjQiZdDTzpevI=; b=s+Mn3FMqDZi1M+X61VeLdvI2FWb8djA6pUN5cNkn2yAoGnAsF3jBi5mdAombxcEtY+ wDtwN54kxX2fJ9PFVCCU1zLl5gsNdbyVHxmUbFoXBQf05bzhRaPUXl2vxnhxdne4lF9I O3v1VQwto3QxnayzkKEdeu8PmiwmrN9XHTwxB7w8Cyhrtlldh3VPqxyvBIIAwBx3FY2a 11u3eEWAYVm4UCtmOdnHZT46O0taFPdEEEP+CmCOBHXHe8gzuuzNj91Vac+k7oHzmyTx jKJn6cbFSjjcOfqhpPfzlnLHDWrMBl2OiUFXYaq81Am4koSwWV6NbSlJBcEK2zg2nUDy ibcA==
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- Sender: zsh-workers-request@xxxxxxx
Current behavior (git master branch):
5.8.0.2-dev % print $notset[(i)] $notset[(I)]
5.8.0.2-dev % typeset emptystr
5.8.0.2-dev % print $emptystr[(i)] $emptystr[(I)]
0 0
5.8.0.2-dev % typeset -a emptyarr
5.8.0.2-dev % print $emptyarr[(i)] $emptyarr[(I)]
1 0
5.8.0.2-dev % unset emptyarr
5.8.0.2-dev % print $emptyarr[(i)] $emptyarr[(I)]
5.8.0.2-dev %
I want to rationalize $emptystr[(i)] by saying that it's searching for
an empty substring and it did find one, so it can't return
(($#emptystr + 1)), but there's not really a $emptystr[0] either. In
the reverse direction, if an empty stubstring is allowed to match
there's no unambiguous answer for $emptystr[(I)].
Behavior on the declarednull branch:
delclarednull % print $notset[(i)] $notset[(I)]
delclarednull % typeset emptystr
delclarednull % print $emptystr[(i)] $emptystr[(I)]
delclarednull % emptystr=""
delclarednull % print $emptystr[(i)] $emptystr[(I)]
0 0
delclarednull % typeset -a emptyarr
delclarednull % print $emptyarr[(i)] $emptyarr[(I)]
delclarednull % emptyarr=()
delclarednull % print $emptyarr[(i)] $emptyarr[(I)]
1 0
delclarednull % unset emptyarr
delclarednull % print $emptyarr[(i)] $emptyarr[(I)]
delclarednull %
Given that the behavior on $emptystr is already poorly defined, I'm
not sure it makes much sense to put any effort into making the
uninitialized $emptyarr case differ from the $notset case.
Further opinions?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author