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 01:04:25PM +0200, Oğuz wrote:
> 15 Aralık 2019 Pazar tarihinde Andreas Kusalananda Kähäri <
> andreas.kahari@xxxxxx> yazdı:
> >
> > In zsh, I suppose you would use ${~1}
> >
>
> Thank you. But don't you think it would be better if GLOB_SUBST was enabled
> by default and `${~spec}` was for disabling it for an individual expansion?
> The way it is it doesn't seem possible to write a portable script which
> works on zsh as well.
>
>
> --
> Oğuz
The fact that zsh does not (by default) perform splitting nor globbing
on unquoted variables is a well known feature of this shell and one of
the things that sets it apart from more conventional POSIX-like shells
like bash or ksh.
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?). However, since this is
something that people seems to want to do, zsh provides emulation of sh:
$ zsh --emulate sh -c 'case foo in $1) echo match; esac' sh '*'
match
See the "emulate" built-in utility in the zshbuiltins(1) manual.
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
Messages sorted by:
Reverse Date,
Date,
Thread,
Author