FDMOVE(1)

NAME
fdmove - move or copy a given file descriptor, then execute a program

SYNOPSIS
fdmove [-c] fdto fdfrom prog...

DESCRIPTION
fdmove moves the file descriptor number fdfrom, to number fdto, then exec(3)s into prog with its arguments. If fdto is open, fdmove closes it before moving fdfrom to it.

‘fdmove a b prog...’ is roughly equivalent to ‘sh -c 'exec prog... a>&b b<&-'’. It means: if you write to fd a now, it will have the same effect as writing to fd b beforehand, and you cannot write to fd b anymore.

‘fdmove -c a b prog...’ is roughly equivalent to ‘sh -c 'exec prog... a>&b'’. It means: you can now write to fd a, and also still write to fd b, and both will have the same effect as writing to fd b beforehand.

It also works with file descriptors that are open for reading!

OPTIONS

-c  Duplicate fdfrom to fdto instead of moving it; do not close fdfrom.

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

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