zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Ross Goldberg <ross.goldberg@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: Adding builtin command option aliases
Date: Wed, 25 Mar 2020 23:17:10 +0000	[thread overview]
Message-ID: <20200325231710.60c57e25@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <CAAEcvMoD77RBSVZ=--aweZ1fcWoEVxRTtmmvZxOAWy2DWt8AhQ@mail.gmail.com>

Ross Goldberg wrote on Wed, 25 Mar 2020 15:21 -0400:
> Would you be willing to add option aliases to builtin commands to align
> with other shells, like bash, so that scripts will be more easily portable
> across multiple shells?

Implementing this doesn't require any changes to zsh itself.  There's
nothing stopping you from writing a «read() { … }» function that wraps
zsh's builtin «read» and supports bash's native options _instead of_
zsh's options (even where option letters have different, incompatible
meanings between the two shells).  You could even package that function
and others like it as a "zsh for bash speakers" shim library, enabled by
a one-line idiom such as «[[ -z $ZSH_VERSION ]] || autoload -U bash-shim».

The "modernish" library might be useful too.

> e.g., bash read has the -a argument, while zsh read has -A.  They seem to
> do the exact same thing.  It's a shame that a script needs to detect which
> shell is running to determine which option to use.

Are you thinking of scripts or of plugins?

Scripts should target either bash or zsh but not both, just like scripts
target either Perl or Python but not both.  Nobody writes programs that
can execute under either Perl or Python depending on what their users
have installed; same for bash and zsh.

On the other hand, for plugins (= code that runs in interactive shells)
it can make sense to try to support both bash and zsh in order to
benefit from economies of scale.

> Providing such interoperability might increase the number of zsh users, and
> ease the transition for macOS 10.15+ & other users

macOS 10.15 users who are used to bash should just install bash and
change their scripts' #! lines appropriately.

Cheers,

Daniel

  reply	other threads:[~2020-03-25 23:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 19:21 Ross Goldberg
2020-03-25 23:17 ` Daniel Shahaf [this message]
2020-03-26  5:22   ` Roman Perepelitsa

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=20200325231710.60c57e25@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=ross.goldberg@gmail.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).