zsh-workers
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Roman Perepelitsa <roman.perepelitsa@gmail.com>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Bug with unset variables
Date: Sat, 21 Nov 2020 19:49:15 -0600	[thread overview]
Message-ID: <CAMP44s2LRtJLMc-RWX6_o7qO_cshfcuWL0-NtrWfqYp9o7HcEA@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7a3vOa2+YXpOS0eCGTr_TGNe1uhPBu+B1Xb_4OmmhJk1A@mail.gmail.com>

On Tue, Nov 17, 2020 at 2:54 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Mon, Nov 16, 2020 at 11:42 AM Felipe Contreras
> <felipe.contreras@gmail.com> wrote:

> > Python:
> >
> >   foo = None
> >   print(foo) # None
> >   foo = "set"
> >   foo = None # unset()
> >   print(foo) # None
> >
> > Shell:
> >
> >   local foo
> >   echo ${foo-nil} # nil
> >   foo="set"
> >   unset foo
> >   echo ${foo-nil} # nil
> >
> > These are all functionally *exactly* the same. And that's an undeniable fact.
>
> Except your examples are NOT the same.  Your shell example introduces
> what amounts to a ternary test.  In shell
>
> local foo
> echo -n $foo
>
> does not output "nil" or "undefined" or "None", it outputs NOTHING.
> When you throw in ${foo-nil} you're effectively writing (pseudo code)
>
> if the variable foo has no value
> then substitute nil
> else substitute the value of foo
> fi

So?

Is it *functionally* the same or not?

> There literally is no concept of "not defined" in the shell language
> outside of that implicit ternary; undefined is not a first-class
> value.  You cannot write "if [[ $foo == undefined ]]" or any of the
> similar comparisons that can be done in most if not all of the other
> languages you assert are equivalent.  You can use $anydamnthing in the
> shell anywhere an empty string can be used, without producing a null
> dereference or similar error -- unless of course you've activated
> NO_UNSET, which by the way:

This is a smoke screen.

Notions don't change the behavior of the code above.

It either is *functionally* the same, or it isn't.

> > > > The most straightforward way is not necessarily the best way.
>
> And the perfect is often the enemy of the good.  Let's stop throwing
> aphorisms at each other, especially when they can't change decisions
> made decades ago.

My statement was not an aphorism, but even if it was; that doesn't
change the fact that it's true.

I was not the one that brought history into the thread. You are the
one that brought the history, which by definition cannot be changed.

If now you are saying there's no point in talking about something that
can't be changed (the past), then fine by me.

> > KSH_TYPESET does something else that not even ksh does. But another
> > option might make sense.
>
> Which particular something are you thinking of?

My understanding of that option is that it changed the behavior of this:

    typeset var=$(echo one word)

To this:

  builtin typeset var=$(echo one word)

In other words:

  typeset var=one word

But that's not what ksh does, at least the version I have installed.

Anyway, I see now that it's obsolete, so in theory it could be reused.

Cheers.

-- 
Felipe Contreras


  reply	other threads:[~2020-11-22  1:49 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 15:57 Felipe Contreras
2020-11-11 16:13 ` Roman Perepelitsa
2020-11-11 16:56   ` Felipe Contreras
2020-11-11 17:02     ` Roman Perepelitsa
2020-11-11 18:03       ` Felipe Contreras
2020-11-11 18:16         ` Roman Perepelitsa
2020-11-11 20:42           ` Felipe Contreras
2020-11-12  0:20             ` Mikael Magnusson
2020-11-12  1:10               ` Felipe Contreras
2020-11-12  8:45             ` Roman Perepelitsa
2020-11-12 10:47               ` Peter Stephenson
2020-11-12 18:48                 ` Bart Schaefer
2020-11-12 19:49                 ` Felipe Contreras
2020-11-12 18:46               ` Felipe Contreras
2020-11-12 19:10                 ` Roman Perepelitsa
2020-11-12 21:08                   ` Felipe Contreras
2020-11-13  8:51                     ` Roman Perepelitsa
2020-11-14  0:52                       ` Felipe Contreras
2020-11-14  5:41                         ` Roman Perepelitsa
2020-11-16 19:41                           ` Felipe Contreras
2020-11-16 20:22                             ` Roman Perepelitsa
2020-11-17 20:28                               ` Felipe Contreras
2020-11-18 22:45                                 ` Daniel Shahaf
2020-11-22  1:20                                   ` Felipe Contreras
2020-11-23  4:00                                     ` Daniel Shahaf
2020-11-23  6:18                                       ` Felipe Contreras
2020-11-19  2:59                                 ` Bart Schaefer
2020-11-22  1:50                                   ` Felipe Contreras
2020-11-17 20:54                             ` Bart Schaefer
2020-11-22  1:49                               ` Felipe Contreras [this message]
2020-11-23  6:48                                 ` Bart Schaefer
2020-11-23  7:26                                   ` Felipe Contreras
2020-11-23 20:26                                     ` Bart Schaefer
2020-11-23 23:39                                       ` Felipe Contreras
2020-11-24  0:52                                         ` Bart Schaefer
2020-11-25  8:46                                           ` Felipe Contreras
2020-11-27 15:44                                             ` Daniel Shahaf
2020-11-27 20:49                                               ` Felipe Contreras
2020-11-27 20:59                                                 ` Daniel Shahaf
2020-11-27 21:33                                                   ` Bart Schaefer
2020-11-27 23:37                                                     ` Daniel Shahaf
2020-11-27 23:45                                                       ` Bart Schaefer
2020-11-28  0:24                                                       ` Bart Schaefer
2020-11-28  7:32                                                         ` Bart Schaefer
2020-11-28 12:05                                                         ` Felipe Contreras
2020-11-12 19:26                 ` Bart Schaefer
2020-11-12 21:48                   ` Felipe Contreras
2020-11-13 22:17                     ` Bart Schaefer
2020-11-14  0:58                       ` Felipe Contreras
2020-11-11 18:36         ` Bart Schaefer
2020-11-11 21:08           ` Felipe Contreras
2020-11-11 17:02     ` Peter Stephenson
2020-11-11 18:05       ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMP44s2LRtJLMc-RWX6_o7qO_cshfcuWL0-NtrWfqYp9o7HcEA@mail.gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=roman.perepelitsa@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).