3 ms·
One can make it safe if it's worth the effort. In practice I don't ever come across such files but if I was trying to write a script that would work everywhere
by t43562 5y ago
One can make it safe if it's worth the effort. In practice I don't ever come across such files but if I was trying to write a script that would work everywhere I would have to use
find -print0 | sed -r 's#\r#\\r#g;s#\n#\\n#g;s#\x0#\n#g;
... and then I would have to remember to use the filenames in such a way that my escaped newlines would be converted back to real ones at the point where I accessed the file
Newlines in filenames is one of those things that one would personally try to avoid purely because of the problems it can cause.
- cma 5y agoIt is fine for a personal script where you know your files don't have newlines, but for a robust script as part of a package running on other people's systems you'd have to take it into account.