plan9port/man/man3/searchpath.3
Russ Cox 977b25a76a tmac: introduce real manual reference macro instead of overloading IR
The overloading of IR emits magic \X'...' sequences that turn into HTML manual links.
But not all such IR invocations should be manual links;
those had to be written to avoid the IR macro before.
Worse, the \X'...' ending the IR causes troff to emit only a single space after a period.

Defining a new IM macro for manual references fixes both problems.

Fixes #441.
2020-08-13 23:43:43 -04:00

61 lines
1 KiB
Groff

.TH SEARCHPATH 3
.SH NAME
search \- search for named executable
.SH SYNOPSIS
.B #include <u.h>
.br
.B #include <libc.h>
.PP
.B
char* searchpath(char *name)
.SH DESCRIPTION
.I Searchpath
searches for the executable
.I name
in the same way that
.IM sh (1)
and
.IM rc (1)
do.
.PP
The environment variable
.B $PATH
is treated as a colon-separated list of directories in which to look for
.IR name .
An empty string in the list is treated as the current directory.
If an executable named
.I name
is found in one of the directories,
.I searchpath
returns a pointer to a malloced string containing a path
.IB \fR( dir / name \fR,
or simply
.IR name )
suitable for use in
.IM open (3)
or
.IM exec (3) .
.PP
If
.I name
begins with
.B ./ ,
.B ../ ,
or
.B / ,
then the search path is ignored.
If
.I name
exists and is an executable, then
.I searchpath
returns a malloced string containing name.
.PP
The returned buffer should be freed when no longer needed.
If
.I name
is not found,
.I searchpath
returns nil.
.PP
.SH SOURCE
.B \*9/src/lib9/searchpath.c