From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12897 invoked from network); 16 Dec 2003 10:53:53 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 16 Dec 2003 10:53:53 -0000 Received: (qmail 11418 invoked by alias); 16 Dec 2003 10:53:40 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6899 Received: (qmail 11395 invoked from network); 16 Dec 2003 10:53:39 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 16 Dec 2003 10:53:39 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.189.183.235] by sunsite.dk (MessageWall 1.0.8) with SMTP; 16 Dec 2003 10:53:39 -0000 Received: from EXCHANGE02.csr.com (unverified) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.10) with ESMTP id for ; Tue, 16 Dec 2003 10:51:25 +0000 Received: from csr.com ([192.168.144.127]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.5329); Tue, 16 Dec 2003 10:53:07 +0000 To: zsh-users@sunsite.dk Subject: Re: Splitting string to array removes pipe symbol In-reply-to: "Vincent Stemen"'s message of "Tue, 16 Dec 2003 02:34:49 CST." <20031216083449.GA9113@quark.localdomain> Date: Tue, 16 Dec 2003 10:51:29 +0000 Message-ID: <11632.1071571889@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 16 Dec 2003 10:53:07.0264 (UTC) FILETIME=[C9C3F400:01C3C3C2] Vincent Stemen wrote: > However, when the globsubst option is set, it removes the pipe '|' > symbol when it does the split. Here is the trace output. > > +./t:62> cmd=uncompress foobar | cpio -i --quiet --unconditional > +./t:63> cmd=( uncompress foobar cpio -i --quiet --unconditional ) You have null_glob (or maybe csh_null_glob) set. `|' is split to a single bar. Evaluation of the words takes place as if all the elements of the array are arguments, which is different from evaluating as a command. (This is inevitable --- the only way of doing it differently would be to parse the line again completely from scratch after the glob_subst.) In this case, the `|' is treated the same as (|), i.e. either nothing or nothing, and removed since nothing matches it. (You'd normally need the parentheses to stop it being evaluated as a pipe, but it can't be in an argument list.) You can fix this particular problem by quoting, cmd=("${(@)=cmd}") but only because that cancels the effect of glob_subst, so that `|' is just an ordinary character. This may not be what you want. It's likely to be very difficult to force the shell both to split a line into words *and* to parse it again as a full command line without joining it up again. Most people would probably come up with something using `eval'. What you should do depends why you need to split it at all. -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************