When does read prompt for a continuation line?

When does read prompt for a continuation line?

If standard input is a terminal device and the invoking shell is interactive, read shall prompt for a continuation line when it reads an input line ending with a , unless the -r option is specified.

When does a text file end with a new line?

The C standard says that text files must end with a newline or the data after the last newline may not be read properly. A text stream is an ordered sequence of characters composed into lines, each line consisting of zero or more characters plus a terminating new-line character.

What happens if the last line of an input file ends with a backslash?

This occurs if the last line of the input file ends with a . It is for this reason that “if any” is used in “The terminating (if any) shall be removed from the input” in the description. It is not a relaxation of the requirement for standard input to be a text file.

When to read the last line in a text stream?

Data read in from a text stream will necessarily compare equal to the data that were earlier written out to that stream only if: the data consist only of printing characters and the control characters horizontal tab and new-line; no new-line character is immediately preceded by space characters; and the last character is a new-line character.

Can a shell call a file without a newline?

A simple test shows that his observation is accurate: will work for files without a newline at the end (at least on my machine). I’m still surprised to find that the shells drop the last segment (it can’t be called a line because it doesn’t end with a newline) of the input, but there might be sufficient justification in POSIX to do so.

What happens if there is no newline in bash script?

The terminating (if any) shall be removed from the input and the results shall be split into fields as in the shell for the results of parameter expansion (see Field Splitting); […] Note that ‘ (if any)’ (emphasis added in quote)! It seems to me that if there is no newline, it should still read the result.