Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: for syntax differences from ksh
- X-seq: zsh-users 1085
- From: Andrew Main <zefram@xxxxxxxxx>
- To: sweth@xxxxxxxxxxxxxxxxxx (Sweth Chandramouli)
- Subject: Re: for syntax differences from ksh
- Date: Fri, 17 Oct 1997 10:25:20 +0100 (BST)
- Cc: zsh-users@xxxxxxxxxxxxxxx
- In-reply-to: <Pine.3.89.9710161746.A24348-0100000@xxxxxxxxxxxxxxxxxx> from "Sweth Chandramouli" at Oct 16, 97 05:12:51 pm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author