title: Redirect to a script that uses /dev/tty
body: <p>I am writing a git hook that might require human input. According to <a href="https://stackoverflow.com/a/10015707/7069123">this answer</a> one has to use <code>exec &lt; /dev/tty</code> in that script. This does the job, but now there is no possibility to redirect the standard output to that hook (for test purposes). I guess the problem can be narrowed down to a question: how to send a message to <code>/dev/tty</code> in such a way that another process will read it? Not sure if this is even possible.</p>
  
  <p>Here is the minimum reproducible example:</p>
  
  <pre class="lang-sh prettyprint-override"><code># file: target.sh
  
  exec &lt; /dev/tty # we want to use /dev/tty
  read -p  "Type a message: " message
  echo "The message ${message}"
  
  </code></pre>
  
  <p>I tried several solutions like this:</p>
  
  <pre class="lang-sh prettyprint-override"><code>echo -e "foo\n"| tee /dev/tty | source target.sh
  </code></pre>
  
  <p>And it actually prints the message in the console after the <code>read</code> prompt, but the <code>message</code> variable remains unset. Is there any way to fix it? </p>