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

RE: huh? where did the . come from in my $PATH????



>          if [ -d "$i" ]; then
>             PATH=$i:$PATH

>
> Which works niftily, except that at the end of the $PATH is "." !!
>

The very first time PATH is obviously empty and expands to nothing, so you
get
    PATH=$i:

empty PATH component is the same as . (current dir).

Use array `path' instead of scalar PATH:

   path=($i $path)

Or explicitly test if PATH is not empty

  if [[ -n "$PATH" ]]; then
    PATH=$i:$PATH
  else
    PATH=$i
  fi

/andrej



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