From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id a382995a for ; Sun, 15 Dec 2019 21:05:33 +0000 (UTC) Received: (qmail 27336 invoked by alias); 15 Dec 2019 12:03:09 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24540 Received: (qmail 2504 invoked by uid 1010); 15 Dec 2019 12:03:09 -0000 X-Qmail-Scanner-Diagnostics: from hekla.abc.se by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25656. spamassassin: 3.4.2. Clear:RC:0(158.174.61.227):SA:0(-1.9/5.0):. Processed in 1.783566 secs); 15 Dec 2019 12:03:09 -0000 X-Envelope-From: andreas.kahari@abc.se X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at abc.se designates 158.174.61.227 as permitted sender) Date: Sun, 15 Dec 2019 13:02:31 +0100 From: Andreas Kusalananda =?iso-8859-1?B?S+Ro5HJp?= To: =?utf-8?B?T8SfdXo=?= Cc: zsh-users@zsh.org Subject: Re: variable expanding to `*` matches a literal `*` in case cond. construct Message-ID: <20191215120231.GA18473@pooh.my.domain> Mail-Followup-To: =?utf-8?B?T8SfdXo=?= , zsh-users@zsh.org References: <20191215100507.GA23773@pooh.my.domain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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@abc.se> 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