From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26265 invoked from network); 18 Mar 2005 02:42:32 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 Mar 2005 02:42:32 -0000 Received: (qmail 59256 invoked from network); 18 Mar 2005 02:42:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Mar 2005 02:42:26 -0000 Received: (qmail 20755 invoked by alias); 18 Mar 2005 02:42:23 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21002 Received: (qmail 20746 invoked from network); 18 Mar 2005 02:42:23 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 18 Mar 2005 02:42:23 -0000 Received: (qmail 58957 invoked from network); 18 Mar 2005 02:42:23 -0000 Received: from vms040pub.verizon.net (206.46.252.40) by a.mx.sunsite.dk with SMTP; 18 Mar 2005 02:42:19 -0000 Received: from candle.brasslantern.com ([4.11.1.68]) by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IDJ00K130UHRLP1@vms040.mailsrvcs.net> for zsh-workers@sunsite.dk; Thu, 17 Mar 2005 20:42:18 -0600 (CST) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j2I2gGKG000578; Thu, 17 Mar 2005 18:42:16 -0800 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j2I2gGVk000577; Thu, 17 Mar 2005 18:42:16 -0800 Date: Fri, 18 Mar 2005 02:42:16 +0000 From: Bart Schaefer Subject: Re: problem redeclaring path variable (ksh incompatibility) In-reply-to: <4239F9E1.5070009@endbracket.net> To: Michael Wardle Cc: zsh-workers@sunsite.dk Message-id: <1050318024216.ZM575@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <423994CA.4010609@endbracket.net> <1050317165007.ZM32408@candle.brasslantern.com> <4239F9E1.5070009@endbracket.net> Comments: In reply to Michael Wardle "Re: problem redeclaring path variable (ksh incompatibility)" (Mar 18, 8:42am) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Mar 18, 8:42am, Michael Wardle wrote: } Subject: Re: problem redeclaring path variable (ksh incompatibility) } } > Try running your test script with ARGV0=sh in the environment and note } > the difference in behavior. } } It didn't appear to make any difference. Er, I was assuming, because you were posting to a zsh mailing list, that your usual shell was zsh, which is possibly a bad assumption. That is, ARGV0 is magic to zsh -- not to the new zsh being started up, but to the currently running zsh that is printing your PS1 prompt. If your login shell is bash or ksh, the ARGV0=sh isn't going to make any difference. So, first start an interactive zsh, and then from the prompt of that, run "ARGV0=sh zsh -p yourtestscript", and NOT "ARGV0=sh yourtestscript". Or, do "ln -s `which zsh` /tmp/sh" and then "/tmp/sh -p yourtestscript". } Are you sure this hides $path It causes it never to become set in the first place. } or are you just suggesting this should be the normal way to invoke zsh } any time I want it to conform closely to POSIX shell? If you want zsh to conform closely to the POSIX shell you have to make a link to it whose pathname ends in "sh" (actually any string starting with the letter "s" other than "su" will work) and run it via that link. The trick with ARGV0 is a zsh-ism that simulates having done so. } So this works: } typeset path } path= } path="scalar" This declares a local path, but it inherits the special features of the global path. It then makes it empty (redundant), and finally makes it a single-element array. } But this doesn't: } typeset path= } path="scalar" It doesn't work because "typeset path=" fails *entirely* when it prints the "can't assign initial value" error message; consequently you have not succeeded in declaring "path" to be local, and the assigment affects the global. } And neither does this: } typeset path="" } path="scalar" Same problem. } > zsh% func() { emulate ksh; typeset path ; path=scalar ; typeset path } } > zsh% func } > path=(scalar) } } Assuming a -m flag to the final typeset, this certainly verifies what } you said. Right, I forgot the -m is required in 4.2. I tried it in 4.0, in which older version "emulate ksh" does not imply "setopt TYPESET_SILENT".