rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Bug in code which searches for executables
@ 1991-11-16  2:21 David J. Fiander
  1991-11-17  1:20 ` Paul D. Swasey
  1991-11-17  4:23 ` Chris Siebenmann
  0 siblings, 2 replies; 7+ messages in thread
From: David J. Fiander @ 1991-11-16  2:21 UTC (permalink / raw)
  To: rc

I just found a bug in the code which searches for executables.
The problem was unearthed because I do not keep "." in my path.

The problem is that when you type "bin/foo", the program is not
found, but "./bin/foo" works.  To reproduce, remove "." from
your path (since searching the path will find it), cd to / and
type
	bin/echo hi

You should be told that bin/echo could not be found.

The problem is in which().  As you can see from the patch, I
have changed a call to "isabsolute()" which checks to see if
the path starts with /, ./, or ../, to a call to "strchr()" to
see if a "/" appears anywhere in the string for which we are
searching.

*** Standard Input	Fri Nov 15 12:40:09 1991
--- which.c	Fri Nov 15 09:56:23 1991
***************
*** 98,104 ****
  #endif
  	}
  
! 	if (isabsolute(name)) /* absolute pathname? */
  		return rc_access(name, verbose) ? name : NULL;
  
  	len = strlen(name);
--- 98,104 ----
  #endif
  	}
  
! 	if (strchr(name, '/')) /* explicit pathname? */
  		return rc_access(name, verbose) ? name : NULL;
  
  	len = strlen(name);

--
David J. Fiander   |A man ought to read just as inclination leads him; for
<david@golem.uucp> |what he reads as a task will do him little good.


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Bug in code which searches for executables
@ 1991-11-17  2:55 Byron Rakitzis
  0 siblings, 0 replies; 7+ messages in thread
From: Byron Rakitzis @ 1991-11-17  2:55 UTC (permalink / raw)
  To: ps3u+, rc

I'll comment, and say that if you want to execute "bin/foo" when you
really mean "./bin/foo" then you should say what you mean. I don't think
that one solution has much merit or utility over the other, but the fact
is that rc's solution has a simpler rule.


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Bug in code which searches for executables
@ 1991-11-17  4:48 Scott Schwartz
  0 siblings, 0 replies; 7+ messages in thread
From: Scott Schwartz @ 1991-11-17  4:48 UTC (permalink / raw)
  To: byron, ps3u+, rc

| I don't think that one solution has much merit or utility over the other,

I like rc's behavior much better, and I think it has particular
utility.  It enables you to bundle a number of binaries that make up a
software package in a natural way without putting junk in your path,
and without cluttering bin too much.  For example, sccs/get,
pbm/pbmtops, ingres/foo.



^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <9111170123.AA04583@piggy.ucsb.edu>]

end of thread, other threads:[~1991-11-18 18:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-11-16  2:21 Bug in code which searches for executables David J. Fiander
1991-11-17  1:20 ` Paul D. Swasey
1991-11-18 18:09   ` steve
1991-11-17  4:23 ` Chris Siebenmann
1991-11-17  2:55 Byron Rakitzis
1991-11-17  4:48 Scott Schwartz
     [not found] <9111170123.AA04583@piggy.ucsb.edu>
1991-11-17  4:54 ` David J. Fiander

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