FDRESERVE(1)
π FDRESERVE(1) π
Okay bestie, this is fdreserve(1) from the General Commands Manual, and it's giving tiny-utility-with-main-character-energy. No cap. π
π NAME π
fdreserve β update the environment with file descriptors that are guaranteed safe to use, then execute a program.
β¨ SYNOPSIS β¨
fdreserve n prog...
πΈ DESCRIPTION πΈ
So fdreserve tries to reserve n file descriptors.
It sets the FD0, FD1, ..., FDnβ1 environment variables: each FDi contains a valid file descriptor, that can be safely opened.
Then fdreserve exec(3)s into prog with its arguments. Slay. β¨
π Common use π
fdreserve can be used when you do not want to hardcode file descriptors in your scripts. For instance, to create a pipe, you could use:
#!/command/execlineb
fdreserve 2
multisubstitute
{
importas fdr FD0
importas fdw FD1
}
piperw $fdr $fdw
prog...
Warning: fdreserve does not allocate descriptors, it merely returns descriptors that are free at the time it is run. A program like
#!/command/execlineb
fdreserve 3
multisubstitute
{
importas fdr FD0
importas fdw FD1
}
piperw $fdr $fdw
fdreserve 1
multisubstitute
{
importas oldfd FD2
importas newfd FD0
}
prog...
may fail, becauseoldfdandnewfdmay be the same. To avoid that, you should make sure that all descriptors returned byfdreserveare actually allocated before callingfdreserveagain. (Thanks to Paul Jarc[1] for having spotted that case.) π
π¦ SEE ALSO π¦
All the manual-page besties in the neighborhood:
emptyenv(1)envfile(1)exec(1)execline-cd(1)execline-umask(1)exit(1)export(1)fdblock(1)fdclose(1)fdmove(1)fdswap(1)getcwd(1)getpid(1)heredoc(1)piperw(1)posix-cd(1)posix-umask(1)redirfd(1)trap(1)tryexec(1)unexport(1)wait(1)withstdinas(1)exec(3)
This man page is ported from the authoritative documentation at: https://skarnet.org/software/execline/fdreserve.html
π AUTHORS π
- Laurent Bercot
Alexis <flexibeast@gmail.com> (man page port)
π Cute little footer sign-off: source/version is Debian, dated February 14, 2021, and it's for FDRESERVE(1). Bye bestie, go reserve those fds responsibly! π
π«Ά
π¦ where this page comes from
- nixpkgs unstable: execline 2.9.9.2
- nixpkgs unstable: execline-man-pages 2.9.9.1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms