From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125 invoked from network); 2 May 2006 21:47:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 2 May 2006 21:47:55 -0000 Received: (qmail 44480 invoked from network); 2 May 2006 21:47:49 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 2 May 2006 21:47:49 -0000 Received: (qmail 18515 invoked by alias); 2 May 2006 21:47:42 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10200 Received: (qmail 18505 invoked from network); 2 May 2006 21:47:41 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 2 May 2006 21:47:41 -0000 Received: (qmail 43310 invoked from network); 2 May 2006 21:47:41 -0000 Received: from mta09-winn.ispmail.ntl.com (HELO mtaout03-winn.ispmail.ntl.com) (81.103.221.49) by a.mx.sunsite.dk with SMTP; 2 May 2006 21:47:39 -0000 Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com with ESMTP id <20060502214738.WUKU27969.mtaout03-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com> for ; Tue, 2 May 2006 22:47:38 +0100 Received: from pwslaptop.csr.com ([81.107.42.12]) by aamtaout04-winn.ispmail.ntl.com with ESMTP id <20060502214737.ZLWS16086.aamtaout04-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Tue, 2 May 2006 22:47:37 +0100 Received: from pwslaptop.csr.com (pwslaptop.csr.com [127.0.0.1]) by pwslaptop.csr.com (8.13.6/8.13.4) with ESMTP id k42LlWC9003204 for ; Tue, 2 May 2006 22:47:33 +0100 Message-Id: <200605022147.k42LlWC9003204@pwslaptop.csr.com> From: Peter Stephenson To: zsh-users@sunsite.dk (Zsh users list) Subject: Re: print -s and History Expansion In-Reply-To: Your message of "Tue, 02 May 2006 15:10:22 EDT." <20060502191022.GA30399@namib.cs.utk.edu> Date: Tue, 02 May 2006 22:47:32 +0100 Chris Johnson wrote: > Multiword lines issued to history with print -s don't appear to be > considered as multiple words, as evidenced by the unexpected history > expansion found in the following interaction: > > [cjohnson@sissy] ~ S1: print -s 'echo a b c' > [cjohnson@sissy] ~ S1: echo !!:1 > zsh: no such word in event You'll kick yourself when I tell you... to get the line entered in the history as multiple words, pass multiple words to echo: % print -s echo a b c % echo !!:1 a No quotes. You may have come across this obliquely, because the line you were saving came from a scalar variable. In that case, the best thing to do is probably to zplit it. If you've got histverify set it looks like this (else you don't see the final line, just the result of it): % var='echo one "two three" "four five"' % print -s ${(z)var} % print !!:2 % print "two three" A more complicated case is where you already have a set of arguments, but they aren't yet quoted, for example: % array=(echo one 'two three' 'four five') Here, the quotes have already been "used up" in generating the array. You can requote the arguments to get all the parts of a command line like this (again with histverify): % print -s ${(qq)array} % echo !!:$ % print 'four five' That came up with single quotes; (q) would have used backslashes. In other words, there are plenty of ways of doing it, it depends what you're starting with. That should give you enough to be getting on with. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/