Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug with unset variables
- X-seq: zsh-workers 47673
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Subject: Re: Bug with unset variables
- Date: Fri, 27 Nov 2020 14:49:17 -0600
- Archived-at: <https://zsh.org/workers/47673>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-11/CAMP44s2mkpWF-2coUW6u-9W03puSDdhSoF_HNdVbSqohpxvLkQ%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-wr1-f48.google.com) smtp.remote-ip=209.85.221.48; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=IHA9ftREZCtsmJ4VC+9OgScgj8XGkgOFPWoLrvcdNVU=; b=F1kR6ukM1xWYA32mmcbmQ9LZ+NFO1JgMtKXS8CPZUV0lva6G+d8MiysdK3rRnRRQp+ z2Xd5nZZ1B3Fsxg2mC/v9Y3pkuaNAeVFS46FCEgR2fyseHJo9k3dn2/qBidUJ+oi4o4I hqI4jFA8aXB9fTt/5GLOgImYC9CaYV7vYFj6AnmNaO/B026bcsLbUnutl5JCR9KqnE3D WsuJAF5sfwAFkjhVxeMxCXpyPlZxEKK+r3vnnArtMTlKx0cZKINIy9se/2JSkoQNo5eo V+1QcrN5mm9qlS/ky0iZrvWFAt6eVexQIvhZlp9G7AGrzdwJQ+SQvZib8ivKNrPPYRqD T9bg==
- In-reply-to: <20201127154439.GC26720@tarpaulin.shahaf.local2>
- 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>
- References: <CAN=4vMqr-MBuzikqkSJEnY5=hW6xjv_TcW_paZV9oKEXnDsmrw@mail.gmail.com> <CAMP44s0sU0B1fQq=BEJV+jp_jtjxpFbz6K=wqNpukLK4i31P4g@mail.gmail.com> <CAH+w=7a3vOa2+YXpOS0eCGTr_TGNe1uhPBu+B1Xb_4OmmhJk1A@mail.gmail.com> <CAMP44s2LRtJLMc-RWX6_o7qO_cshfcuWL0-NtrWfqYp9o7HcEA@mail.gmail.com> <CAH+w=7YZQA=vhA=-jVzYLvP_XmrN6f5Ra8TH5LsMrza8GVsKvQ@mail.gmail.com> <CAMP44s1m3zNAeZ9Gn3XcG0pHeavD9K_eXOjZz3LGoUvdpzucVA@mail.gmail.com> <CAH+w=7bhs3BVrBMjbcxPhrxh0fXMKeBVooNknLts+4QxHQYOZA@mail.gmail.com> <CAMP44s0QMzJuMPoMZ1BR=+Y2_n4iEE-coXVtmFTdaHj4AuxTVw@mail.gmail.com> <CAH+w=7Z+Brh5KfwUJakoaKfQ39WQbYoRELyfpu3YO1Ro-Ewvfg@mail.gmail.com> <CAMP44s1RLs-ASYFyvjvj7eGta5_WnsXSH_8jAXf-Zufk569E1Q@mail.gmail.com> <20201127154439.GC26720@tarpaulin.shahaf.local2>
- Sender: zsh-workers-request@xxxxxxx
On Fri, Nov 27, 2020 at 9:44 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Felipe Contreras wrote on Wed, Nov 25, 2020 at 02:46:40 -0600:
> > Maybe there's a better way to describe this fact. Maybe Git's notion
> > of logically separate changes [1] helps (e.g. you should not mix
> > whitespace cleanups with functional changes). But the fact is that in
> > virtually all languages (and bash and ksh) there's an idiom to declare
> > a local variable and *only* declare a local variable (not do anything
> > else).
> >
> > Can we at least agree on that? In zsh typeset does *two* things.
>
> I'd rather say that «typeset» does one thing — it ${verb}s a variable
> (for some value of $verb) — and the zsh data model doesn't feature
> a "Not really a value" value, so the variable necessarily gets _some_
> value, like «int foo;» in C.
If it's really one thing, then why does adding it in the example above
changes the behavior in *two* ways?
func () {
[[ -n "$1" ]] && var=$1
dosomething ${var-other}
}
func () {
typeset var
[[ -n "$1" ]] && var=$1
dosomething ${var-other}
}
--
Felipe Contreras
Messages sorted by:
Reverse Date,
Date,
Thread,
Author