Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[Fwd: Parameter Expansion questions]



 
--- Begin Message ---
> >   splitpath=${buf:gs/:/ /}
> 
> That's doing a substitution, rather than field splitting.  Since the
> effect you're asking for is actually a substitution, rather than field
> splitting (since you're just joining up the fields again anyway), this
> is logically the correct thing to do.
> 
> OTOH, I suspect that you *really* want to be using an array parameter.
> $path is an array version of $PATH, so you don't even need to do the
> splitting manually in that case.

Here's a larger fragment of the function I'm using, that is a wrapper
around vi to check several directories for a file to edit. What is the
recommended way to accomplish this in zsh, hopefully while retaining
ksh compatibility also? I would like to get rid of the $shell_type
nonsense and the ${=editpath} syntax in the loop.

Thanks.

_______


   # paths to search
   editpath=${EDITPATH:-"$PATH:$CDPATH"}

   IFS=:

   if [ $shell_type = 'zsh' ] ; then   <<< $shell_type
      editpath=${editpath:gs/:/ /}
   else
      editpath=$editpath
   fi

   IFS="$BACKUP_IFS"

   for name in $* ; do

      for dir in ${=editpath} ; do     <<< ${=editpath}

         # find/edit the file

      done

   done

--- End Message ---


Messages sorted by: Reverse Date, Date, Thread, Author