What happens if the last line of fstab is not terminated by a newline?
Why do people get a warning when that last line is not terminated by a newline?
What happens if the last line of fstab is not terminated by a newline?
Why do people get a warning when that last line is not terminated by a newline?
A line is a sequence of characters terminated by a newline character. The characters that appear after the last newline of a file are not part of a line.
Such a file that has characters after the last newline is not a text file as per the POSIX definition of a text file, and the behaviour of text utilities is unspecified in that case and in practice, behaviour varies:
sed
)cut
)read
which returns a non-zero exit status when reading a non terminated line.So even if the mount
, swapon
, fsck
... utilities (those which typically read /etc/fstab) understand non-terminated lines, some script that process that file may still fail. You should always make sure text files are terminated by a newline character (unless they're empty). Text editors should do that by default. You generally need to go through hoops to remove that last newline characters.