3 ms·
"You can use any characters in filenames, except NUL and slash." "Including LF?" "Yes." "So what does find do when it encounters a file with an LF in its nam
by billpg 3y ago
"You can use any characters in filenames, except NUL and slash."
"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!"
- Anthony-G 3y agoYou 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 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. ¹ https://www.gnu.org/software/coreutils/quotes.html https://www.gnu.org/software/coreutils/quotes.html ² https://unix.stackexchange.com/a/258691 https://unix.stackexchange.com/a/258691