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

Re: Double Colon in $PATH



On Sun, May 28, 2006 at 05:32:04PM +0200, Julius Plenz wrote:
> Hi!
> 
> I recently discovered (rather by accident, though) that a double-colon
> in the PATH variable is treated by Zsh (Ash and Bash, too) as if there was
> ".", the current directory, in the PATH variable.
> 
> Example:
> 
> prompt> echo $PATH && pwd
> ::
> /bin
> prompt> ls
> [directory listing of /bin]
> 
> Now this is really confusing me. I've already asked several people,
> and neither one of them could tell my why Zsh (and other shells) do
> this. I'd appreciate it very much if any of you guys could give me a
> hint or explain this behaviour to me.

Spending a few minutes reading man-pages reveals the following:


The man-page for bash(1) says:

 [...]
       PATH   The  search  path for commands.  It is a colon-separated list of
	      directories in which the shell looks for commands  (see  COMMAND
	      EXECUTION  below).   A  zero-length (null) directory name in the
	      value of PATH indicates the current directory.  A null directory
	      name  may  appear  as  two  adjacent colons, or as an initial or
	      trailing colon.  The default path is  system-dependent,  and  is
	      set  by  the administrator who installs bash.  A common value is
	      `/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''.
 [...]

The sh(1) manpage (on FreeBSD) says:

 [...]
     2.   The shell searches each entry in PATH in turn for the command. The
	  value of the PATH variable should be a series of entries separated
	  by colons.  Each entry consists of a directory name.  The current
	  directory may be indicated implicitly by an empty directory name, or
	  explicitly by a single period.
 [...]


I assume that zsh treats empty directory names in $PATH in the same
way even though I could not find it in the manpages.


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@xxxxxxxxxxxxx



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