rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re:  Things I'd like whatis to have:
@ 1993-03-10 21:36 rsalz
  0 siblings, 0 replies; 6+ messages in thread
From: rsalz @ 1993-03-10 21:36 UTC (permalink / raw)
  To: cks, rc

here's "whatis -p", called "wh" from a standard old BBN program.
    fn wh { i=() {
	for (i in $path) {
	    test -x $i^/^$1 && echo $i^/^$1 && return 0
	}
	echo $1 not found >[1=2]
	return 1
    } }


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

* Re:  Things I'd like whatis to have:
@ 1993-03-11 15:49 rsalz
  0 siblings, 0 replies; 6+ messages in thread
From: rsalz @ 1993-03-11 15:49 UTC (permalink / raw)
  To: cks, culliton, rc, rsalz

>This has a slight bug, to avoid getting caught by directories the test
Pedantically, yes.  I like seeing directory name/executable clobbers.  It
is normally not an issue for me since I just threw the "&& return 0" on to
what I posted; normally I don't have that -- I want to see all versions.

Chris was concerned about the cost of exec'ing all those test(1)'s.
This version cuts it down to one:
    fn mywhat {
	@ for (i) {
	    fn $i
	    whatis $i
	}
    }


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

* Re:  Things I'd like whatis to have:
@ 1993-03-10 23:21 Tom Culliton x2278
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Culliton x2278 @ 1993-03-10 23:21 UTC (permalink / raw)
  To: cks, rc, rsalz

> From: rsalz@osf.org
> 
> here's "whatis -p", called "wh" from a standard old BBN program.
>     fn wh { i=() {
> 	for (i in $path) {
> 	    test -x $i^/^$1 && echo $i^/^$1 && return 0
> 	}
> 	echo $1 not found >[1=2]
> 	return 1
>     } }

This has a slight bug, to avoid getting caught by directories the test
should be:

	test -f $i^/^$1 -a -x $i^/^$1

Tom


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

* Re: Things I'd like whatis to have:
@ 1993-03-10 22:16 Tom Culliton x2278
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Culliton x2278 @ 1993-03-10 22:16 UTC (permalink / raw)
  To: cks, rc

To me this seems like an idea worth at least considering, it would also
be nice to have an option to see the whole chain of candidates.  (the
function and possibly the builtin or executable(s))  I once had a
function, that called a script, that called the binary, all with the
same name, and it stopped working when another version appeared in my
path.  (Memory falters on whether this was from changing the $path or
an executable in a new place.)

I ended up writing the following rc function to tell me where an
executable was (or could be) coming from.  It should probably also
check if there is a function by the name given, before listing the
executable files, but I tend to know what functions are in my .rcrc
file.

fn whereis { i=() p=() { 
	for (i)
		for (p in $path)
			if (test -f $p/$i -a -x $p/$i)
				echo $p/$i
}}


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

* Re: Things I'd like whatis to have:
  1993-03-10 21:22 Chris Siebenmann
@ 1993-03-10 21:29 ` mycroft
  0 siblings, 0 replies; 6+ messages in thread
From: mycroft @ 1993-03-10 21:29 UTC (permalink / raw)
  To: Chris Siebenmann; +Cc: rc


I was thinking of `whatis -b', where the `b' means `builtin'.  You can
guess what it would do.



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

* Things I'd like whatis to have:
@ 1993-03-10 21:22 Chris Siebenmann
  1993-03-10 21:29 ` mycroft
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Siebenmann @ 1993-03-10 21:22 UTC (permalink / raw)
  To: rc

 Arguments -e, -f, and -p to restrict the search to environment variables,
functions, and programs. The default case would continue to be '-efp'.
(I suggest -e and -f for symmetry; I'm really only interested in -p)

	- cks


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

end of thread, other threads:[~1993-03-11 15:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-03-10 21:36 Things I'd like whatis to have: rsalz
  -- strict thread matches above, loose matches on Subject: below --
1993-03-11 15:49 rsalz
1993-03-10 23:21 Tom Culliton x2278
1993-03-10 22:16 Tom Culliton x2278
1993-03-10 21:22 Chris Siebenmann
1993-03-10 21:29 ` mycroft

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