title: Quit less when pipe closes
body: <p>As part of a bash script, I want to run a program repeatedly, and redirect the output to <code>less</code>. The program has an interactive element, so the goal is that when you exit the program via the window's X button, it is restarted via the script. This part works great, but when I use a pipe to <code>less</code>, the program does not automatically restart until I go to the console and press <code>q</code>. The relevant part of the script:</p>
  
  <pre><code>while :
  do
      program | less
  done
  </code></pre>
  
  <p>I want to make <code>less</code> quit itself when the pipe closes, so that the program restarts without any user intervention. (That way it behaves just as if the pipe was not there, except while the program is running you can consult the console to view the output of the current run.)</p>
  
  <p>Alternative solutions to this problem are also welcome.</p>