zsh-users
 help / color / mirror / code / Atom feed
* huh?  where did the . come from in my $PATH????
@ 1999-04-14 13:24 TjL
  1999-04-14 13:38 ` Andrej Borsenkow
  0 siblings, 1 reply; 2+ messages in thread
From: TjL @ 1999-04-14 13:24 UTC (permalink / raw)
  To: Zsh Users


I have this automatic $PATH maker in .zshenv:

unset PATH

for i in \
          /etc                     \
          /usr                     \
          /bin                     \
          /sbin                    \
          /usr/etc                 \
          /usr/ucb                 \
          /usr/bin                 \
          /usr/gnu/bin             \
          /usr/local/etc           \
          /usr/local/bin           \
          /usr/local/sbin          \
          /usr/local/gnu/bin       \
          /usr/local/shell-scripts \
          $HOME/Library/bin        \
          $HOME/bin                \
          $HOME/Unix/bin                     
do

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


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

See:

# echo $PATH
/usr/local/Users/fpc/Unix/bin:/usr/local/shell-scripts:/usr/local/gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/local/etc:/usr/gnu/bin:/usr/bin:/usr/ucb:/usr/etc:/bin:/usr:/etc:.


Now I don't know where that "." came from, but it really really should not
be there!  In fact, I'd almost recommend a "REFUSE_DOT_IN_PATH" option
when compiling zsh!!! (force ./ if you want to execute a command in $PWD
if $PWD is not in $PATH

Any clues what is going wrong?  This is w/ an older version of zsh... I
don't even know where to get the recent versions now with the patches and
whatnot...

TjL





^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: huh?  where did the . come from in my $PATH????
  1999-04-14 13:24 huh? where did the . come from in my $PATH???? TjL
@ 1999-04-14 13:38 ` Andrej Borsenkow
  0 siblings, 0 replies; 2+ messages in thread
From: Andrej Borsenkow @ 1999-04-14 13:38 UTC (permalink / raw)
  To: TjL, Zsh Users

>          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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-04-14 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-14 13:24 huh? where did the . come from in my $PATH???? TjL
1999-04-14 13:38 ` Andrej Borsenkow

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).