From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6617 invoked from network); 15 Sep 2001 17:35:13 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 Sep 2001 17:35:13 -0000 Received: (qmail 28564 invoked by alias); 15 Sep 2001 17:34:49 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4226 Received: (qmail 28550 invoked from network); 15 Sep 2001 17:34:48 -0000 From: Bart Schaefer Message-Id: <1010915173427.ZM1780@candle.brasslantern.com> Date: Sat, 15 Sep 2001 17:34:27 +0000 In-Reply-To: <20010914214218.A23939@thelonious.new.ox.ac.uk> Comments: In reply to Adam Spiers "retrieving invocation arguments" (Sep 14, 9:42pm) References: <20010914214218.A23939@thelonious.new.ox.ac.uk> X-Mailer: Z-Mail (5.0.0 30July97) To: Adam Spiers , zsh-users@sunsite.dk Subject: Re: retrieving invocation arguments MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 14, 9:42pm, Adam Spiers wrote: } } What's the best way of retrieving the arguments with which zsh was } invoked? By examining $0, $-, and $*. This is imperfect; $- doesn't tell you what options were turned off. However, in a non-interactive shell, the only interesting option that is on by default is BG_NICE (-6). It is also not possible to get the command argument to -c, and when -c is given the first non-option argument after the command to -c becomes $0 rather than being included in $*. That is, zsh -fc 'echo $0' foo will print "foo". The best way to detect whether -c was given appears to be [[ -o shinstdin && ! -o interactive ]] and to find out whether $0 is really an argument following the command, [[ $# -gt 0 || $0:t != $ZSH_NAME ]] Of course you can fool that, e.g. zsh -c '[[ $# -gt 0 || $0:t != $ZSH_NAME ]] && echo Got $0' zsh won't print anything, but that's a pretty obscure case. } It doesn't appear to be stored in any parameter set by the shell. AFAIK this is true of all shells. } Worth doing? It wouldn't be particularly difficult, but what's the application you have in mind? -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net