Commit c2d5a17
committed
Fix TTY detection using /dev/tty instead of stdin fd
[ -t 0 ] checks whether stdin (fd 0) is a terminal, but git redirects
stdin to /dev/null for all hooks — so the check was always false, causing
the non-interactive warning to appear even in a normal terminal session.
The correct check is to attempt to open /dev/tty (the controlling terminal).
A terminal session always has an accessible /dev/tty even when stdin is
redirected; a GUI Git client has no controlling terminal at all, so the open
fails. This reliably distinguishes the two environments.1 parent c165f75 commit c2d5a17
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
0 commit comments