Overview
The exec command replaces the current process with the specified command, but when used without arguments, it allows dynamic redirection.
For example, in the post Prompt for confirmation when pushing directly to master, the following code appeared:
I didn't quite understand it at first, so I decided to look into it.
Usage
The code from Prompt for confirmation when pushing directly to master does the following:
It passes the input from the current terminal (/dev/tty) to the standard input of the exec command. (This is a bit hard to understand...)
Thoughts
This seems useful in situations where standard input cannot be read for some reason.
References
- SEEKPOINT - exec Redirect
- UNIX/Linux no Heya - Command: exec
- exec - Replace the shell with the executed command
- Qiita - Issues and solutions when processing screen output with Process Substitution and exec redirect, and the story of sleeping infinitely
- Qiita - Various controls for shell input/output