Re:Filenames and Pathnames in Shell: How to Do It Correctly
by Anthony-G on Tuesday June 20, 2023 @01:32PM
(#36407494)
You would think that this would be common-sense. In 2010, David Wheeler (author of the featured article) proposed to the Austin Group that control characters – in particular newline (and TAB and ESC) – be forbidden in filenames: https://www.austingroupbugs.net/view.php?id=251 Unfortunately, it has yet to be implemented. :(
I also note that in 2016 the authors of GNU coreutils took a lot of flak when they changed the default behaviour of ls to quote filenames with special characters¹². Personally, I’d be having stern words with anyone that produced path names with anything funkier than a space character.
"Including LF?"
"Yes."
"So what does find do when it encounters a file with an LF in its name?"
"It outputs the name including the LF."
"Without quoting it?"
"Right."
"But how can something reading the output from find know what's an LF in a filename or an LF separating lines?"
"You can use -print0 so it separates files with a NUL character, which filenames can't use."
"Wouldn't it be simpler to prohibit control characters from filenames?"
"Never!"