SEARCHPATH(3)

πŸ“¦ version 0_git20260208, in alpine 3.24, arch rolling, nixos 26.05, nixpkgs unstable

πŸŽ€ NAME πŸŽ€

search β€” search for named executable. This is the SEARCHPATH(3) page, bestie, and it's literally all about finding an executable by name. ✨

✨ SYNOPSIS ✨

#include <u.h>
#include <libc.h>

char*     searchpath(char *name)

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so searchpath searches for the executable name in the exact same way that sh(1) and rc(1) do. No cap. 🫢

The environment variable $PATH is treated as a colon-separated list of directories where it should look for name. An empty string in that list is treated as the current directory. If an executable named name is found in one of those directories, searchpath returns a pointer to a malloced string containing a path (dir/name, or simply name) suitable for use in open(3) or exec(3). It's giving β€œhere's your path, go wild.” πŸ’…

If name begins with ./, ../, or /, then the search path is ignored. If name exists and is an executable, then searchpath returns a malloced string containing name. Iconic shortcut behavior, fr fr. ⭐

The returned buffer should be freed when no longer needed. If name is not found, searchpath returns nil. That's the whole vibe check. πŸ’–

🌸 SOURCE 🌸

/src/lib9/searchpath.c

That's where the source lives, and yes, it ate. πŸ”₯


Final lil sign-off: this is the SEARCHPATH(3) page from the Library Functions Manual, and the source file is /src/lib9/searchpath.c. The original footer only repeats SEARCHPATH(3) and doesn't show a separate version or date, so there's no extra number to quote β€” just this cute end note. πŸ’–πŸ’