COMPLETE(3)
π COMPLETE(3) β like, the file name completion page, bestie
okay so this is complete and freecompletion from the Library Functions Manual, and it's literally the entire personality of tab-completion in plan9-land. come on. let's get into it π
β¨ NAME β¨
complete, freecompletion β file name completion, aka the moment your shell guesses what you meant and honestly? it ate π
πΈ SYNOPSIS πΈ
#include <u.h>
#include <libc.h>
#include <complete.h>
typedef struct CompletionCompletion;
struct Completion{
uchar advance;
uchar complete;
char *string;
int nmatch;
int nfile;
char **filename;
};
Completion* complete(char *dir, char *s);
void freecompletion(Completion *c);
yes bestie, that first typedef really does say struct CompletionCompletion with no space. that's not a typo on my end, that's just how it is. copy it exactly, don't @ me π
π¦ DESCRIPTION π¦
so complete is, like, the main character here β it implements file name completion fr fr. you hand it a directory dir and a string s, and it comes back with a whole analysis of the file names sitting in that directory that begin with the string s. vibe check complete β
the fields nmatch and nfile get set to the number of files that match the prefix, and filename gets filled in with their names. and heads up π β if the file that's named is a directory, a slash character gets appended to it. slay.
if no files match the string, then nmatch will be zero... but complete doesn't just give up π it returns the full set of files in the directory, with nfile set to their number. so you always get something, icon behavior.
now the flags, because this is where it gets good:
advanceβ reports whether the stringscan be extended without changing the set of files that match. if it's true,stringwill be set to the extension β meaning the caller can append the value ofstringtosto extend the embryonic file name unambiguously. no cap, that's the whole point π«Άcompleteβ reports whether the extended file name uniquely identifies a file. if it's true,stringwill be suffixed with a blank... or a slash and a blank, depending on whether the resulting file name identifies a plain file or a directory. the way that detail matters π
and freecompletion? that's the cleanup crew π§Ή it frees a Completion structure and its contents. always free your structs bestie, that's the rule.
also, fun fact for the rio/acme girlies: in rio(1) and acme(1), file name completion is triggered by a control-F character or an Insert character. iconic keybind tbh π
π SOURCE π
/src/libcomplete
π SEE ALSO π
π DIAGNOSTICS π
if the directory is unreadable, or there's just, like, some other error going on?completereturns a null pointer and setserrstr. so check that pointer, bestie, please π
π BUGS π
the behavior of file name completion should be controlled by the plumber. yeah. that's the bug. that's it. it's giving "known issue, no notes" π
okay that's the whole page, and honestly? it's lowkey iconic. this was COMPLETE(3) from the Library Functions Manual, and ngl that footer being just COMPLETE(3) again is so on brand β no date, no version, just the vibe. periodt β¨π¦π
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms