From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9844 invoked from network); 28 May 1999 23:14:07 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 May 1999 23:14:07 -0000 Received: (qmail 3056 invoked by alias); 28 May 1999 23:13:52 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2348 Received: (qmail 3049 invoked from network); 28 May 1999 23:13:51 -0000 Subject: Re: variable containing the current command In-Reply-To: <990526221741.ZM22768@candle.brasslantern.com> from Bart Schaefer at "May 26, 1999 10:17:41 pm" From: benjamin@cs.ualberta.ca To: zsh-users@sunsite.auc.dk Date: Fri, 28 May 1999 17:13:24 -0600 (MDT) X-Mailer: ELM [version 2.4ME+ PL53 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <19990528231330Z14058-10359+234@scapa.cs.ualberta.ca> Thanks. That's EXACTLY what I was looking for. Reading the man page carefully reveals that I am too stupid to live. :) Ben Bart Schaefer said: > On May 26, 2:23pm, benjamin@cs.ualberta.ca wrote: > > Subject: variable containing the current command > > Is there a zsh environment variable that contains the current command > > so that it can be referenced in preexec() or precmd() (or ideally both)? > > In preexec, the positional parameter $1 holds the entire command line just > as it was read from the terminal (after history expansion but before any > other expansions/substitutions). > > You could have preexec copy this to a global parameter where precmd can > see it later. > > On May 26, 5:40pm, Sweth Chandramouli wrote: > > Subject: Re: variable containing the current command > > $_ is almost what you are looking for; it is supposed to be set for > > any command to the full name of that command. > > That's not quite correct. From the doc: > > `_' > The last argument of the previous command. Also, this parameter > is set in the environment of every command executed to the full > pathname of the command. > > So it's only during the execution of a command that you can find the path > of that command in $_. Once you're back in the shell (as during precmd), > you get the last word of the previous command line (not the first; try > your "ls" example with some file name arguments to "ls"). > > As for this: > > > (astaroth/3)~: ls > > Ready to do:preexec > > I suspect it has something to do with how or when preexec is executed. > PWS could tell us more, but he's out for a few days. > -- Benjamin Korvemaker benjamin@cs.ualberta.ca The programmer's national anthem is 'AAAAAAAARRRRGHHHHH!!'.