title: Bash: Is there a way to require the enter key to be pushed with read -n once character limit is reached?
body: <p>Is there a way to require the enter key to be pushed with read -n once character limit is reached, rather than automatically jumping to the following line in the script?</p>
  <p>For example, in the following script:</p>
  <pre><code>echo &quot;Please enter your credentials below&quot; 
  read -p &quot;Please enter your username: &quot; -e -n 15 usern
  read -p &quot;Please enter your password: &quot; -s -e -n 15 passw
  </code></pre>
  <p>Once 15 chars are entered for the username, it automatically jumps to the password prompt. However, it would be more user-friendly to simply stop allowing input once the 15 chars are reached (besides the backspace key and enter key), and require the user to press enter to continue to the password prompt. This is how most logins work, after all...</p>
  <p>I'm aware that I could use a while loop/if statement restricting the char limit in the usern variable (e.g. with -gt), but I was wondering how I could specifically limit the user to pressing either backspace or enter (or even the arrow keys if they want to edit a single character from their username, but I'm not worried about this right now), once those 15 characters are reached, and REQUIRE the user to press enter to continue to the following prompt.</p>
  <p>Hopefully what I am asking for makes sense. Thanks to everyone in advance!</p>