zsh-workers
 help / color / Atom feed
* Adding builtin command option aliases
@ 2020-03-25 19:21 Ross Goldberg
  2020-03-25 23:17 ` Daniel Shahaf
  0 siblings, 1 reply; 3+ messages in thread
From: Ross Goldberg @ 2020-03-25 19:21 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

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?

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.

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

Thanks,

Ross

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding builtin command option aliases
  2020-03-25 19:21 Adding builtin command option aliases Ross Goldberg
@ 2020-03-25 23:17 ` Daniel Shahaf
  2020-03-26  5:22   ` Roman Perepelitsa
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2020-03-25 23:17 UTC (permalink / raw)
  To: Ross Goldberg; +Cc: zsh-workers

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding builtin command option aliases
  2020-03-25 23:17 ` Daniel Shahaf
@ 2020-03-26  5:22   ` Roman Perepelitsa
  0 siblings, 0 replies; 3+ messages in thread
From: Roman Perepelitsa @ 2020-03-26  5:22 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Ross Goldberg, Zsh hackers list

On Thu, Mar 26, 2020 at 12:18 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> macOS 10.15 users who are used to bash should just install bash and
> change their scripts' #! lines appropriately.

I believe Catalina comes with bash preinstalled. What Apple has
changes in this release is that login shell for new users defaults to
zsh.

Roman.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 19:21 Adding builtin command option aliases Ross Goldberg
2020-03-25 23:17 ` Daniel Shahaf
2020-03-26  5:22   ` Roman Perepelitsa

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git