Skip to main content
added 339 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k

echo outputs a newline at the end of the string, not at the beginning.

printf interprets \n as a newline, but \n%s prints the newline before the rest of the output, not after it.

And since with read -s, we suppress the terminal local echo of what is being typed, when the user presses Enter, that also suppresses the CRLF echo.

In any case, the syntax to read the password should be IFS= read -r passcode, or it wouldn't work properly if the password contained backslash or $IFS characters.

echo outputs a newline at the end of the string, not at the beginning.

printf interprets \n as a newline, but \n%s prints the newline before the rest of the output, not after it.

echo outputs a newline at the end of the string, not at the beginning.

printf interprets \n as a newline, but \n%s prints the newline before the rest of the output, not after it.

And since with read -s, we suppress the terminal local echo of what is being typed, when the user presses Enter, that also suppresses the CRLF echo.

In any case, the syntax to read the password should be IFS= read -r passcode, or it wouldn't work properly if the password contained backslash or $IFS characters.

deleted 1 character in body
Source Link
choroba
  • 49.6k
  • 7
  • 92
  • 119

echo outputs a newline at the end of the string, not at the beginning.

printf insterpretsinterprets \n as a newline, but \n%s prints the newline before the rest of the output, not after it.

echo outputs a newline at the end of the string, not at the beginning.

printf insterprets \n as a newline, but \n%s prints the newline before the rest of the output, not after it.

echo outputs a newline at the end of the string, not at the beginning.

printf interprets \n as a newline, but \n%s prints the newline before the rest of the output, not after it.

Source Link
choroba
  • 49.6k
  • 7
  • 92
  • 119

echo outputs a newline at the end of the string, not at the beginning.

printf insterprets \n as a newline, but \n%s prints the newline before the rest of the output, not after it.