5 ms·
This is still the default behavior of `ls` in OpenBSD, very likely all BSD's. I also remember reading one man page on a Linux machine (which presumably is using
by barrister 6y ago
This is still the default behavior of `ls` in OpenBSD, very likely all BSD's. I also remember reading one man page on a Linux machine (which presumably is using GNU core utilities) that stated `ls` would always print per line if it was directed to anything other than stdout, e.g. a pipe.
- _kst_ 6y agoI think you mean anything other than a terminal. Whatever its output is directed to, whether it's a pipe, a file, or anything else, is the stdout of the ls process.
- pwdisswordfish0 6y agoDo those BSDs allow newline chars to appear in file names?
- barrister 6y agoYes, and they also don't add single quotes to filenames that contain whitespace characters when displaying them as mentioned in the article.
- pwdisswordfish0 6y agoSo then BSD's behavior isn't very useful then, right? You can't actually rely on 1 filename = 1 line.
- barrister 6y agoNo because in the case of the "ls" command, it replaces non-printable characters with a question mark '?', including newline characters. I believe the actual source code for this behavior can be seen here: https://github.com/openbsd/src/blob/master/bin/ls/utf8.c https://github.com/openbsd/src/blob/master/bin/ls/utf8.c
- pwdisswordfish0 6y agoSo then BSD can't be guaranteed to accurately display the filename. Either way, you have to pick a side.