nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] Getting the location of the of the nmh executables from a script

2015-01-28 12:06:21
The heuristic I finally settled on is to find the last component of $PATH that
contains, at least, scan, comp, pick, dist, dist, mark, whatnow, and whom. I
figure that nobody would dare get rid of all of those.

Paul Fox <pgf(_at_)foxharp(_dot_)boston(_dot_)ma(_dot_)us> writes:
ralph wrote:
Hi Norm,

Neither 'command -v scan' nor 'which scan' works for me. I want to
name the script, from which I want to know where nmh's scan is
located. "scan". I want to know its location so I can invoke it.

OK, so you've your own `scan' script that you want to be found earlier
in PATH and have it call the next one that's found if PATH searching
continued?  The way I normally do that is to hardcode the path to the
next one in line, I must admit.

in bash, i do:
mhbin=$(type -p install-mh)  # find the install-mh executable
mhbin=${mhbin%/*}            # strip the last '/' and anything that follows

the first line could be replaced by
mhbin=`which install-mh`

the second could be replaced by something clever in expr or sed.

later, my script says:
$mhbin/comp   # run the real 'comp' command

    Norman Shapiro

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>