Retr0id 3 days ago

vanilla ls has never been particularly chainable - https://mywiki.wooledge.org/ParsingLs

1
machinestops 3 days ago

A lot of this post hinges on the fact that newlines in filenames were legal, and that people wrote shell without handling quoting correctly. While quoting (as well as ls altering filenames) is still an issue, find -print0, read -d '', and similar are no longer neccessary. Newlines are now forbidden in filenames: https://blog.toast.cafe/posix2024-xcu

threePointFive 3 days ago

> Newlines are now forbidden in filenames

No. To quote that article

> A bunch of C functions are now encouraged to report EILSEQ if the last component of a pathname to a file they are to create contains a newline

This, yes, makes newlines in filenames effectively illegal on operating systems strictly conforming to the new POSIX standard. However, older systems will not be enforcing this and any operating system which exposes a syscall interface that does not require libc (such as Linux) is also not required to emit any errors. The only time even in the future that you should NOT worry about handling the newline case is on filesystems where it's is expressly forbidden, such as NTFS.

machinestops 3 days ago

Most utilities that create files are encouraged to error on newline filenames, which makes this effective illegality stronger. The post also discusses the future of this encouragement, which is turning it into a requirement.

> However, older systems will not be enforcing this

Eventually, newlines in filenames will go the way of /usr/xpg4/bin/sh.

I'd like to note that up until this point, there hasn't (and isn't) been a fully POSIX compliant way to do many shell operations on newline containing filenames. They are already effectively unsupported, and the standard that adds support also discourages them from being created and used. The best way to handle them up until this point has been to not use sh(1).

CJefferson 3 days ago

Linux isn't POSIX compliant, and as far as I know has no plans to ban newlines in filenames, or even add an option to disable newlines.

machinestops 3 days ago

In past, there have been Linux-based operating systems that have been certified as Single Unix Specification compliant, and part of said specification is POSIX. I would imagine GNU and Busybox and Musl will be willing to implement the changes proposed by POSIX 2024, which inevitably leads down the road of newlines being banned.

CJefferson 2 days ago

Howw would that work? Checking strings passed to open and rejecting them? Would we then have undeletable files, as we can't refer to their filenames?

pyuser583 3 days ago

I know Linux allows newlines in filenames, but every time I hear it I want to drink.