Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: variable expanding to `*` matches a literal `*` in case cond. construct



On Sun, Dec 15, 2019 at 03:50:20PM +0300, O??uz wrote:
> On Sun, Dec 15, 2019 at 3:02 PM Andreas Kusalananda Kähäri <
> andreas.kahari@xxxxxx> wrote:
> Well-known by experienced users. Since MacOS switched to zsh, and MacOS's
> userbase mostly consists of people who have no idea what they're doing when
> it comes to command line; I think it's not unreasonable to expect them to
> complain about how shell scripts/commands they find on the internet doesn't
> work on their precious cheese graters. That's my concern, maybe I'm wrong,
> I don't know.

These features are why we "experienced users" prefer zsh.  If it
worked exactly like the Posix shell, what would be the point in
using zsh?

> > Wanting to write scripts that "works with any shell" is IMHO a
> > misdirected efforti (why would you want to run code written for one
> > language with the interpreter for another?).
>
> I agree with that, but still, most shells out there are compatible with
> each other to some extent. I just expected zsh too to be so.

What you normally need are not scripts compatible with every
shell, but *portable* scripts that run on any system.  Your best
bet ist to put

 #!/bin/sh
 (or /bin/bash for bash based systems; Linux etc.)

at the beginning of the script and make it executable. The manual
of autoconf has a chapter about writing portable shell scripts.

  https://www.gnu.org/software/autoconf/manual/autoconf-2.64/html_node/Portable-Shell.html

I recommend to read it, it lists many differences between shells
and is really helpful if you ever write software that must compile
on many systems.

> > See the "emulate" built-in utility in the zshbuiltins(1) manual.
>
> I guess this is a new feature. The latest version available on Ubuntu 18.04
> repo doesn't have such an option as `--emulate`, you need to call `emulate`
> from within the script; which is even worse.

What is actually the point in feeding scripts that have been
written for one shell to another?  Posix shells have (by
specification) some bugs that make scripting harder than
necessary.  Zsh replaces these bugs with sensible behaviour that
makes writing complex scripts for zsh much easier than for the
Posix shell, bash and others.

Some of zsh's strength are:

 + Powerful interactive mode
 + Advanced scripting

but if you're looking for something that works everywhere, /bin/sh
or /bin/bash is the better choice.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt



Messages sorted by: Reverse Date, Date, Thread, Author