Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: The emulation rabbit-hole RE typeset/unset
- X-seq: zsh-workers 47694
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: The emulation rabbit-hole RE typeset/unset
- Date: Sat, 28 Nov 2020 05:35:55 -0600
- Archived-at: <https://zsh.org/workers/47694>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-11/CAMP44s1b5N2_PfmQEgvXhdGzcXgLOK6i1CpABfo-XK%3DRGf-hRw%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-wm1-f50.google.com) smtp.remote-ip=209.85.128.50; 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=4anUhEOpN9iy5F3lGORkU9dlCz6QfUqjJXvaq8j9RJg=; b=t+VurdMALCT1nxRMXZRWtRXSal5zyCcO9YsszoZe2pQIw5/ZYKsF1gMp8OV7zLKI74 B5o7w1U97X9LF/fo67toVYdBbpTc//DfWSEyM87kPdGZLvTEj+eHb2EY2LcYaFcxjbU8 KpaunMrRw2YKmjKqHDXWsbx64bTGWahRe/IWMaJi7QmtkEi0gY1u/tfjoaUIxxb4M8tB FW4oxuXZEKYyUnOx9MSwTwjKHuNiw8/EmwF7LQmQ7FvSSLBPO1Fi32l2vZR3hQHbQ7w9 9FULWPkp8RSiOyelYzk38ds4bkL76C1vsKJlAOCxN8t0+M5ORs+3kLkojk9Hxm8P7DBG pDYg==
- In-reply-to: <CAH+w=7aQ_pNqHtgEqV6s02Z+V6Aih2g8hebMbjxHgdYJVKXYFQ@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: <CAH+w=7Zag5MG5D=cRS2UMSsqJ0t=iw5MH9j8=HBO1Q77nbs03w@mail.gmail.com> <20201125131921.vay7h3xk5qn4odgg@chazelas.org> <CAMP44s0-ki=TBzTwnqx10FcTLX4mbphwN88UCx0+h97JTecBWA@mail.gmail.com> <CAH+w=7bs9E7whJLugMLOXG05R-2S8Hjt+OOKK_KN+SMxv-Vvaw@mail.gmail.com> <CAMP44s2Ge-pOn1-gEXkq=oJX7ohL-b_20s9mJZAo1LB=ow+Duw@mail.gmail.com> <CAH+w=7bHCrpwbkZBOgwjwF7M9uo+1_ZEa53hxSwE2fuuBuQfyw@mail.gmail.com> <CAMP44s0WSt_J7TjyPEKvH9TxzWBvTVFTB-pK26G+9SacYeQrAw@mail.gmail.com> <CAH+w=7YtBvrpuXUM=MuHVRuBjf8uiRozKLJsHvYXJr9Cx=J-rQ@mail.gmail.com> <CAMP44s3s0dXtirZhi5e_Tir+3KKn2Kw4hseEj0uH12a7HB5Y=Q@mail.gmail.com> <CAH+w=7ZVthOMB=jJ+KkU1WipL2mbCgD69HfUtxGnu6Mbx1rOog@mail.gmail.com> <CAMP44s2ZJg75KEh+vL+EUOgJUF+oB6TLn5-1h55ktcKR67ZeJg@mail.gmail.com> <CAH+w=7arBoRxmFRH7wL_Sh-0tRe1Xyo_GKze+jkSdvYep7NMWg@mail.gmail.com> <CAMP44s1i6uC72LhqGmt_hg-YUoFtJTKcC6o2qTGLHZJ3tB56CA@mail.gmail.com> <CAH+w=7ZxhRr1TYFe_SuKaT5TKsceh7RDTeQ-hfcZF08ctWeTvg@mail.gmail.com> <CAMP44s1Vb7BLHMaJTVwA=y1X3+UuocA3PGCuGVJRDMHAaG7zwg@mail.gmail.com> <CAH+w=7aQ_pNqHtgEqV6s02Z+V6Aih2g8hebMbjxHgdYJVKXYFQ@mail.gmail.com>
- Sender: zsh-workers-request@xxxxxxx
On Fri, Nov 27, 2020 at 6:37 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Fri, Nov 27, 2020 at 4:00 PM Felipe Contreras
> <felipe.contreras@xxxxxxxxx> wrote:
> >
> > This is a bit tautological, because if the variable is unset, it can't
> > be anything else but a string: param_is_unset(p) ->
> > param_type_is_string(p).
>
> This is manifestly not true in ksh and bash, because:
>
> [[ ${foo-nil} = nil ]] implies foo is unset
> { typeset -i foo } declares foo is an integer, not a string
> function ff { typeset -i foo; echo ${foo-nil}; } outputs nil
All right, that is true.
But then, if we have this:
typeset -i foo
At this point "foo" is unset (in bash and ksh). It does not have a
value, and ${foo-nil} is nil. So for all intents and purposes it is
nil.
Then, we decide to add 1 to it:
((foo += 1))
The result is 1 (in bash and ksh).
This is interesting.
Irrespective of the fact that foo is unset, you can still add 1 to it,
so in bash and ksh it doesn't matter that foo initially is *not* 0;
you can still add to it.
So this:
f() { ((foo +=1 )); echo ${foo-nil}; }
Returns the same in all shells: 1. You don't need to define "foo" first.
So the statement 'the only useful "declared but not set" variable is a
simple scalar' does not seem to be true.
An integer is not a "simple scalar", and seems to be useful unset.
Or am I missing something?
Cheers.
--
Felipe Contreras
Messages sorted by:
Reverse Date,
Date,
Thread,
Author