Redirecting with the exec Command

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