FDMOVE(1)

πŸ“¦ version 2.9.9.2, in nixpkgs unstable

🌸 FDMOVE(1) 🌸

okay so bestie, you're reading the fdmove page from the General Commands Manual β€” yes, that General Commands Manual β€” and it's genuinely one of those tiny tools that eats. let me put you on πŸ’…

✨ NAME ✨

fdmove β€” move or copy a given file descriptor, then execute a program 🫢

✨ SYNOPSIS ✨

fdmove [-c] fdto fdfrom prog...

✨ DESCRIPTION ✨

okay so here's the whole vibe: fdmove takes the file descriptor number fdfrom and moves it to number fdto, and then it exec(3)s into prog with its arguments. that's it. that's the whole personality. πŸŽ€

and like, important detail: if fdto is already open, fdmove closes it first, before it moves fdfrom onto it. no leftovers, no mess, we love a clean slate ✨

so fdmove a b prog... is roughly equivalent to this little number:

sh -c 'exec prog... a>&b b<&-'

which means β€” and stay with me here β€” if you write to fd a now, it'll have the exact same effect as writing to fd b beforehand. and you cannot write to fd b anymore. it's gone. moved out. no forwarding address 😭

and then fdmove -c a b prog... is roughly equivalent to:

sh -c 'exec prog... a>&b'

which means: you can now write to fd a, and you can also still write to fd b, and both of those do the same thing as writing to fd b beforehand. two doors, one room. iconic. πŸ‘‘

and the plot twist?? it also works with file descriptors that are open for reading! not just writing! equal opportunity file descriptors fr fr πŸ’–

✨ OPTIONS ✨

  • -c β€” duplicate fdfrom to fdto instead of moving it; do not close fdfrom. basically keep the original around too, no cap πŸ¦‹

✨ SEE ALSO ✨

emptyenv(1), envfile(1), exec(1), execline-cd(1), execline-umask(1), exit(1), export(1), fdblock(1), fdclose(1), fdreserve(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/fdmove.html β€” go check the source bestie, it's giving credibility 🌈

✨ AUTHORS ✨

  • Laurent Bercot
  • Alexis <flexibeast@gmail.com> (man page port)

and that's the whole page, bestie! πŸ’œ this one's from Debian, dated February 16, 2021, and it's the FDMOVE(1) page β€” go move some file descriptors, you're gonna slay 🧚⭐πŸ”₯

πŸ“¦ where this page comes from