From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24475 invoked from network); 17 Oct 1997 11:24:54 -0000 Received: from math.gatech.edu (root@130.207.146.50) by ns1.primenet.com.au with SMTP; 17 Oct 1997 11:24:54 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id FAA10598; Fri, 17 Oct 1997 05:31:08 -0400 (EDT) Resent-Date: Fri, 17 Oct 1997 05:30:47 -0400 (EDT) From: Andrew Main Message-Id: <199710170925.KAA05948@taos.demon.co.uk> Subject: Re: for syntax differences from ksh To: sweth@gwis2.circ.gwu.edu (Sweth Chandramouli) Date: Fri, 17 Oct 1997 10:25:20 +0100 (BST) Cc: zsh-users@math.gatech.edu In-Reply-To: from "Sweth Chandramouli" at Oct 16, 97 05:12:51 pm X-Loop: zefram@tao.co.uk X-Headers: in preparation X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"g_lzD2.0.0b2.71pHq"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1085 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Sweth Chandramouli wrote: > i wrote the following function in ksh to easily add directories >to my path. it worked fine there, but when i try to use it in zsh, it fails. > >addpath () { >for pathdir in $*; do > if test -d $pathdir; then > PATH=$PATH:$pathdir > fi; >done >} This function is correct for zsh. > (actually, the line is >addpath $pathlist >where pathlist is defined as the list of dirs, separated by spaces) There's your problem. By default, zsh does not perform field splitting on the result of parameter substitution. There are three possible solutions. First, you can set the option SH_WORD_SPLIT, making zsh act like sh/ksh in this regard. Second, you could set that option for just the one substitution, by rewriting it as `$=pathlist'. The best solution would be to use an array variable, which will allow you to handle pathnames containing whitespace. -zefram