From 8252cc30d4460e3e39699adfd25eba9bf10ce94e Mon Sep 17 00:00:00 2001 From: Thorsten Ho Date: Mon, 16 Oct 2023 14:38:24 +0200 Subject: [PATCH] Fix commit issues on missing /dev/tty This fixes an issue encountered during committing on WSL2 with PHPStorm. The message was: .git/hooks/prepare-commit-msg: 2: cannot open /dev/tty: No such device or address --- src/Hook/Template/Docker.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Hook/Template/Docker.php b/src/Hook/Template/Docker.php index 9e553d15..0a67f057 100644 --- a/src/Hook/Template/Docker.php +++ b/src/Hook/Template/Docker.php @@ -68,7 +68,9 @@ public function getCode(string $hook): string $path2Config = $this->pathInfo->getConfigPath(); $config = $path2Config !== CH::CONFIG ? ' --configuration=' . escapeshellarg($path2Config) : ''; $bootstrap = !empty($this->config->getBootstrap()) ? ' --bootstrap=' . $this->config->getBootstrap() : ''; - $tty = Hooks::allowsUserInput($hook) ? 'exec < /dev/tty' : ''; + $tty = Hooks::allowsUserInput($hook) + ? "if sh -c \": >/dev/tty\" >/dev/null 2>/dev/null; then\n\texec < /dev/tty\nfi" + : ''; $lines = [ '#!/bin/sh',