Playing devil’s advocate, the Unix/Linux model of things doesn’t have to be “normal” either. Why should file extensions be a thing? Why shouldn’t people use their desktop as they please? Why put drivers in the kernel?
Playing devil’s advocate, the Unix/Linux model of things doesn’t have to be “normal” either. Why should file extensions be a thing? Why shouldn’t people use their desktop as they please? Why put drivers in the kernel?
Because they are part of the name of the file. Note: my file manager even identifies the mime type without extension. That is how it should be, changing the extension should not make the file harder to use. To this day, AFAIK, windows file manager still uses the extension to identify file type, thus allowing the user to easily change it may break expectation. GNOME's nautilus, KDE's Dolphin and even Apple's finder do it right: press f2 and you can rename the file without changing the extension, unless you go out of you way for that.
It is also a security breach: image.jpg and image.exe may look the same.
> Why shouldn’t people use their desktop as they please?
Sure they should! But the fact that the OS lacks a working /tmp incentivizes a form of use that is disorganized and ugly.
> Why put drivers in the kernel?
Read about complaints about wacom tablet driver phoning home or printers drivers doing the same. To use my wacom tablet I simply plugged it. Since it is on the kernel, it will work on any architecture the kernel support. They didn't spent a dime to make it working on my raspi, for example. Also, once it is in the kernel, whoever change any internal api will fix every driver code to keep it working, so things that work once will work for a very long time. I met people who lost a TCE scanner and an ASUS mini projector because it wasn't supported by the most recent windows versions. The ASUS mini projector (disclaimer: I had a little involvement in the development of its driver) works on my rockpi4 just by plugging it; the windows experience with it is far from that simple.
This is exactly how Windows Explorer works by default too.
But you're right, and I wanted to drop the same hint. As much as I dislike the OS, I have to admit they made some improvements.
No, probing around the file content with a gazillion format-specific heuristics/hacks is not how it should be.
This is a security problem because it makes the probing code a giant attack surface, and there have been CVEs related to precisely that.
The file type should be determined from metadata only (simple, regular and without format-specific idiosyncrasies). Whether that metadata should be a suffix on the filename that's easy to mess up inadvertently is debatable, but Windows has the right idea here.
My favorite file browsers do it wonderfully. I don't even care when using network because performance is good enough and updates are done async.
You've just confounded two different concerns: filetype identification by file managers and the interface to rename files. If you're not just cribbing some bad Intro to UX course, you'd know that Windows Explorer has always gone out of its way to howl bloody murder when you accidentally changed the file extension, and since Windows XP most rename file controls preserve the file extension. Your thinking was very sloppy here.
Identifying files by heuristics is a VERY dangerous game. Different systems have implemented it differently over the years, classic Mac OS in particular offering a fascinating alternative to file extensions.
> Also, once it is in the kernel, whoever change any internal api will fix every driver code to keep it working, so things that work once will work for a very long time.
Sometimes. Not always. Don't blindly worship code you haven't read.
Some apps do care about extensions but this is not really an OS thing. And some files have to have specific names but that's really a thing in any OS.
Executables are executed by the kernel. They have the x bit set and a header that the kernel reads to decide what to do with them.
A regular POSIX shell will simply call the `exec` syscall on the path provided. It may set up some environment variables or parse some arguments, but it will not actually read the file. In fact you can have a file with executable permissions, but not read permissions.
The kernel determines how to execute the file based on its Magic Numbers, which are the first few bytes in certain file formats that will specify what type of file it is. It just so happens that the one for scripts are `#!`.
But my main point was that extensions aren't really a thing used at OS level to determine file type like on Windows, like the OP said.
They're not that important on Linux. Making files without extensions is simple and common.
Honestly, file extensions are an annoying GUI thing. In the command line you pass the file as parameter to a program, the extension doesn't matter. Simply clicking on a file provides no information to the operating system about what program to invoke though, there needs to be additional metadata. So graphical environments created this notion of file associations based on extensions to the file name.
The problem is Windows does different things with files based on their extension, and hides their extension by default. Linux does neither.
I know you meant +x, but that is limited to only some files.