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: Wed, 11 Nov 2020 15:08:58 -0600	[thread overview]
Message-ID: <CAMP44s3Lvk0oYArfPyN2SsjhCutOYpJ9Gw0s4kt0+nLuhxcmkg@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZXojQV+fAwrRdCVcWzrnza9HRio7G0342X3sBs=Rh8rw@mail.gmail.com>

On Wed, Nov 11, 2020 at 12:36 PM Bart Schaefer
<schaefer@brasslantern.com> wrote:
> On Wed, Nov 11, 2020 at 10:04 AM Felipe Contreras <felipe.contreras@gmail.com> wrote:

>> And what is the reason why this is not the default?
>
> Remember that doc Daniel quoted?
>
> 30 years-ish ago, when implementing zsh as a new shell from scratch, that documentation was used to decide the behavior.  At that point the other shells that supported "typeset" were not freeware -- they required expensive licenses or were bundled with commercial operating systems.  So the implementation followed the doc (sometimes, it followed a misunderstanding of the doc, which is why for example zsh syntax to specify integer bases differs from ksh) without examples to which to compare.
>
> Zsh development has always followed a principle of NOT arbitrarily breaking past usage without an extremely good reason (something I wish other APIs would have taken to heart over the years ... IMO there would be much less abandonware sitting in metaphorical dustbins ... but I digress).  So by the time anyone noticed, the behavior you see now was standard practice for zsh in its default modes.

This is *in general* a good principle to follow, and it does indeed
salvage plenty of projects from the dustbin, but that doesn't mean the
rule must be necessarily unquestionably followed.

I argue there almost always is a sweet spot. While almost always it's
bad to break APIs, not changing them ever also sends projects to the
dustbin.

The biggest mistake projects make isn't breaking API, but *how* they
do it. There are few disadvantages of setting a flag to turn on the
new behavior so that people can try it, then enabling the flag by
default, while always leaving the possibility to turn the flag off for
the people that prefer the old behavior.

Doing this once say every 10 years seems like a sensible thing to do.
Just have a list of all these proposed changes so they don't get lost.
That's what major versions are for.

> Your original example can use ${var:-other} if empty string has no explicit meaning in context.

I know, but it does have meaning. It is a suffix, so I want to use a
space by default "${sfx- }", but only $sfx is unset, it can be set
with an empty value, in which case I don't want any suffix.

And it's not even my code, it's bash code I'm trying to emulate and
leverage from zsh.

>> Either way, if "emulate ksh" is supposed to emulate ksh, then it's not
>> working properly in this instance.
>
> Despite the name, "emulate ksh" is not supposed to perfectly emulate ksh.  All it does is change the values of "setopt" to match ksh as closely as possible.  A more complete emulation is achieved by actually starting zsh from a symlink named "ksh" (or one of a few equivalent ways).  Same goes for "sh" and "bash" (although there is little difference for those two).

Right, but if virtually all shells do this, and it is a known
discrepancy, and I'd argue it's the behavior that makes the most
sense, I think it makes sense to have a flag for it.

Cheers.

-- 
Felipe Contreras


  reply	other threads:[~2020-11-11 21:09 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
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 [this message]
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=CAMP44s3Lvk0oYArfPyN2SsjhCutOYpJ9Gw0s4kt0+nLuhxcmkg@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).