zsh-workers
 help / color / mirror / code / Atom feed
* bug with empty path
@ 1996-11-25 14:33 Peter Stephenson
  1996-12-03 16:57 ` Zoltan Hidvegi
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 1996-11-25 14:33 UTC (permalink / raw)
  To: Zsh hackers list

The lines:
  path=()
and
  PATH=
have different effects: the first produces an empty path array, the
second a path with one blank element.  This turns up in the following:

% cd /usr/bin
% PATH=
% ls
<listing>
% path=()
% ls
zsh: command not found: ls

which doesn't strike me as right; both should use the current
directory if there is no path.  The only `nice' way I can see of doing
it (without messing the arrays around) is handling a totally empty
path the same way as a path with a single blank element.

*** Src/exec.c.path	Mon Nov 25 15:26:47 1996
--- Src/exec.c	Mon Nov 25 15:28:12 1996
***************
*** 331,336 ****
--- 331,341 ----
  	if (isgooderr(ee, *nn ? nn : "/"))
  	    eno = ee;
      }
+     if (!*path) {
+ 	ee = zexecve(arg0, argv);
+ 	if (isgooderr(ee, ""))
+ 	    eno = ee;
+     }
      for (pp = path; *pp; pp++)
  	if (!(*pp)[0] || ((*pp)[0] == '.' && !(*pp)[1])) {
  	    ee = zexecve(arg0, argv);

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


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

* Re: bug with empty path
  1996-11-25 14:33 bug with empty path Peter Stephenson
@ 1996-12-03 16:57 ` Zoltan Hidvegi
  1996-12-04  9:00   ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Zoltan Hidvegi @ 1996-12-03 16:57 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

Peter Stephenson wrote:
> The lines:
>   path=()
> and
>   PATH=
> have different effects: the first produces an empty path array, the
> second a path with one blank element.  This turns up in the following:

I do not think it is a bug.  Of course other shells couldn't set an empty
path but zsh is better than that.  The path is really an array and the PATH
scalar is just a representation which has this inefficiency.

One may want to use a really empty path sometimes which is best achieved
with path=().

Zoltan


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

* Re: bug with empty path
  1996-12-03 16:57 ` Zoltan Hidvegi
@ 1996-12-04  9:00   ` Peter Stephenson
  1996-12-04 20:59     ` Zoltan Hidvegi
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 1996-12-04  9:00 UTC (permalink / raw)
  To: Zsh hackers list

Zoltan Hidvegi wrote:
> Peter Stephenson wrote:
> > The lines:
> >   path=()
> > and
> >   PATH=
> > have different effects: the first produces an empty path array, the
> > second a path with one blank element.  This turns up in the following:
> 
> I do not think it is a bug.  Of course other shells couldn't set an empty
> path but zsh is better than that.  The path is really an array and the PATH
> scalar is just a representation which has this inefficiency.
> 
> One may want to use a really empty path sometimes which is best achieved
> with path=().

I see the point, but do you really want to try and explain this to the
average user?  ``The PATH is sometimes empty, and sometimes really empty,
but only if you set it as an array; if it looks empty, it may be empty
or really empty; if it's empty but not really empty it pretends to be
set to the current directory...''

Besides which, when passed as an environment variable --- even down to another
zsh --- the only possibilities are either not having it set or an empty
PATH (which is therefore not really empty in the above sense).

Still, there's some confusion in having both $path and $PATH which is
probably unavoidable, so I can live with it.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


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

* Re: bug with empty path
  1996-12-04  9:00   ` Peter Stephenson
@ 1996-12-04 20:59     ` Zoltan Hidvegi
  0 siblings, 0 replies; 4+ messages in thread
From: Zoltan Hidvegi @ 1996-12-04 20:59 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

Peter Stephenson wrote:
> I see the point, but do you really want to try and explain this to the
> average user?  ``The PATH is sometimes empty, and sometimes really empty,
> but only if you set it as an array; if it looks empty, it may be empty
> or really empty; if it's empty but not really empty it pretends to be
> set to the current directory...''

I tell the user that path is an array and the real thing is the path
variable.  PATH just tries to represent is as a scalar for compatibility
reasons.

> Still, there's some confusion in having both $path and $PATH which is
> probably unavoidable, so I can live with it.

When zsh is called as sh, there is no path just PATH.

And if we modify the behaviour of path we should also modify the other
variables: mailpath, fpath, module_path or any other array/scalar pairs.
But that would just remove functionality with cost of addig extra code.

Zoltan


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

end of thread, other threads:[~1996-12-04 21:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-11-25 14:33 bug with empty path Peter Stephenson
1996-12-03 16:57 ` Zoltan Hidvegi
1996-12-04  9:00   ` Peter Stephenson
1996-12-04 20:59     ` Zoltan Hidvegi

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).