News for hackers. Stuff that matters.
Re:Fixing Unix/Linux/Posix Filenames: Control Characters (Su... by catern on Saturday March 09, 2019 @02:43PM (#19348027)
The problem is not in the filesystem, it's in the shell. Stop writing shell scripts for tasks that need to be robust! None of these problems hit you when using a better programming language like Python. (Yes, Python 3 has a bit of an impedance mismatch between its native Unicode string type and the filesystem, but that just makes for slightly uglier code, not actual bugs)
Re:Fixing Unix/Linux/Posix Filenames: Control Characters (Su... by blablabla123 on Saturday March 09, 2019 @02:56PM (#19348118)
I wonder how much effort it would take, to make the shell robust when it comes to this. Obviously in Python 3 it's not a big deal to process UTF8 strings with control characters, store them in a database and still have decent XSS protection with no ("manual") input filter. But with Python you loose the flexibility of pipes, combining commands tersely on the fly.
Re:Fixing Unix/Linux/Posix Filenames: Control Characters (Su... by JdeBP on Sunday March 10, 2019 @05:06AM (#19351099)
Of course, the problem here is in thinking that there is "the" shell, and that one needs to always use a POSIX compatible shell for interactive login. (The C shell users of the world should disabuse one of that particular notion, if nothing else.)

* https://news.ycombinator.com/item?id=11672023

* https://news.ycombinator.com/item?id=17989710

Re:Fixing Unix/Linux/Posix Filenames: Control Characters (Su... by benj111 on Saturday March 09, 2019 @03:47PM (#19348382)
Surely the problem is the 'Everything is a stream of bytes' model?

Eg:

Ls | foo | bar

Ls just prints nl separated strings, no metadata, nothing to tell you what it is.

In current practical terms that means avoiding the shell, that isn't inherent though. I guess powershell avoids this issue.

Re:Fixing Unix/Linux/Posix Filenames: Control Characters (Su... by JdeBP on Sunday March 10, 2019 @05:00AM (#19351075)
Hence Greg Wooledge's famous advice not to parse the output of ls. As catern points out, in a fully-fledged systems programming language, one can just directly call the library routines that read directories. And thereby obtain metadata without having to parse it from locale-dependent forms, too.

* https://mywiki.wooledge.org/ParsingLs

* https://unix.stackexchange.com/a/503711/5132