execline: the fdmove program
Keywords: execline command fdmove file descriptor dup dup2

execline
Software
skarnet.org

# The `fdmove` program

`fdmove` moves or copies a given file descriptor, then executes a program.

## Interface

         fdmove [ -c ] fdto fdfrom prog...

`fdmove` moves the file descriptor number fdfrom, to number fdto, then execs into prog with its arguments. If fdto is open, `fdmove` closes it before moving fdfrom to it.

## Options

- `-c` : duplicate fdfrom to fdto instead of moving it; do not close fdfrom.

## Notes

- `fdmove -c a b prog...` is roughly equivalent to `sh -c 'exec prog... a>&b'`
- `fdmove a b prog...` is roughly equivalent to `sh -c 'exec prog... a>&b b<&-'`