3 ms·
Unfortunately filenames can have newlines so this isn't safe for robust scripts.
by cma 5y ago
Unfortunately filenames can have newlines so this isn't safe for robust scripts.
- t43562 5y agoOne 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.