Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug with unset variables
- X-seq: zsh-workers 47536
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Subject: Re: Bug with unset variables
- Date: Wed, 11 Nov 2020 12:03:28 -0600
- Archived-at: <https://zsh.org/workers/47536>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-11/CAMP44s3s3CWX0b-hxFTb8tWM3HasHngY1Spg_8V6jWErSLTOEA%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: 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; bh=MhMUbHcOy210XI1SA0nPp+uRBvQFp5jx8JP4litkrOQ=; b=gM1SRA5C8gwfQRkV1mluknuEZcfgDt/n8+EFBGQRmJ7DjnjHpMAzXOjNqxsIKBC83Z vErHcCLGplEIsR2KVkH8T9wEnjhfMA1UzZLJTGePZM6M1Z4XWzsa2FCBvxi8MogwNi5Z Z0SFhE77dRIKQssfZlAiur1cDdBgt7ulQzyZrRkpneKC3TnQs7b5lp0tA9WgdLNST3Es u9MENqhjha2yfe8VCdmd9KeowGkSXN+Bhko+T76zOj2SOnrGDylafHYCOMgHEYfb5XTC YkAehHIAoSdjL18PVKXxEzSPiQttC88i63MjrNvAxNNghegs0eKnPR0iGLjTQE6uioh9 3gKg==
- In-reply-to: <CAN=4vMqcHMASwR23vdFDTOzxuKtxfan6aOK01kTS2habuh14xA@mail.gmail.com>
- 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: <CAMP44s2x20VKt0Kp3OuUEDVhE+7EL5yVOpCfkKnKr7opRu1v4A@mail.gmail.com> <CAN=4vMrvB--NSrRJEyUaaxhyErgyF4=+0da+=TE2mU_3KXopyA@mail.gmail.com> <CAMP44s29X6VBRwpwVj-anXax0UU6WRnukmUqrpoweM_cqbDdTQ@mail.gmail.com> <CAN=4vMqcHMASwR23vdFDTOzxuKtxfan6aOK01kTS2habuh14xA@mail.gmail.com>
- Sender: zsh-workers-request@xxxxxxx
On Wed, Nov 11, 2020 at 11:02 AM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> On Wed, Nov 11, 2020 at 5:56 PM Felipe Contreras
> <felipe.contreras@xxxxxxxxx> wrote:
> >
> > If I actually do something on the foo() function:
> >
> > typeset var
> > [[ -n "$1" ]] && var=$1
> > echo "var: '${var-other}'"
> >
> > I would expect two things: 1) var is not set when I exit the function,
> > and 2) var is not set until I specifically set it.
> >
> > I can get both in ksh and bash, but not in zsh. In zsh I have to
> > choose either 1) with typeset, or 2) by removing typeset.
> >
> > How do you suggest I get both in zsh?
>
> Add `unset var` right after `typeset var`.
And what is the reason why this is not the default?
Not only does this behavior differ from all other shells, but
basically all languages.
Either way, if "emulate ksh" is supposed to emulate ksh, then it's not
working properly in this instance.
--
Felipe Contreras
Messages sorted by:
Reverse Date,
Date,
Thread,
Author