News for hackers. Stuff that matters.
Re:Filenames and Pathnames in Shell: How to Do It Correctly by tredre3 on Monday June 19, 2023 @08:35PM (#36398248)
Your link was an interesting read, he does make good points along with clear examples.

I'm one of those who believes that linux paths should have more limitations. I also believe they should be case insensitive. Both opinions are highly controversial, unfortunately

I guess it comes down to whether you believe paths are there to serve humans or machines. If you believe it should serve humans, then you understand why allowing a - prefix or case sensitivity causes unnecessary problems.

On the other hand if you believe that paths are there to serve the machine, then the fewer "arbitrary" limitations the better. The devs know best, after all.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by fbdab103 on Monday June 19, 2023 @08:52PM (#36398389)
>If you believe it should serve humans, then you understand why allowing a - prefix or case sensitivity causes unnecessary problems.

Serving humans feels like it should take whatever garbage I shove down its throat and be happy to receive. Similarly, I think many humans would like to differentiate between, "resumefinal.docx" and "resumeFINAL.docx"

Re:Filenames and Pathnames in Shell: How to Do It Correctly by lmm on Monday June 19, 2023 @11:54PM (#36399508)
> Similarly, I think many humans would like to differentiate between, "resumefinal.docx" and "resumeFINAL.docx"

I strongly disagree. Those sound exactly the same. If you had a physical filing cabinet and asked someone to get a document from the final folder (which is supposed to be the human-friendly metaphor we're using here), they would happily open a folder labeled FINAL, and be quite confused if you had distinct final and FINAL folders.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by smackeyacky on Tuesday June 20, 2023 @01:24AM (#36400060)
If they shout the name, you know to look for the upper case version :-)
Re:Filenames and Pathnames in Shell: How to Do It Correctly by eviks on Tuesday June 20, 2023 @12:19AM (#36399661)
Humans don't speak binary garbage, so it's a disservice to them to happily swallow/spit it out

Cap sensitivity is a much lesser mistake

Re:Filenames and Pathnames in Shell: How to Do It Correctly by coldtea on Tuesday June 20, 2023 @05:29AM (#36401613)
>Similarly, I think many humans would like to differentiate between, "resumefinal.docx" and "resumeFINAL.docx"

Would they? Both are the "final resume" Word document...

Humans don't care about case in distinguishing names. Considering case differences as important distinctions between names (of files in this case) is something instilled from using computers, not a human trait. That's a concern for coders, proof-readers, and other OCD types.

Not to mention that the most popular Desktop OSes (Windows, MacOS) don't care for file case either. They preserve it for visual display is you set it, but two filenames with differences in case only are the same file - and can't coexist.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by jackthetab on Monday June 19, 2023 @09:01PM (#36398444)
> The devs know best, after all.

Which may be why they gave us these options to put in our ~/.inputrc

``` set completion-ignore-case on set completion-prefix-display-length 2 set completion-map-case on ```

Technically filenames and paths are still case-sensitive, but with these settings they practically aren't.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by jackthetab on Monday June 19, 2023 @09:02PM (#36398452)
ARGH! How does one do code on this site?

I meant: set completion-ignore-case on

set completion-prefix-display-length 2

set completion-map-case on

Re:Filenames and Pathnames in Shell: How to Do It Correctly by js2 on Monday June 19, 2023 @09:58PM (#36398830)
Indent by 4 spaces.

    like this
Re:Filenames and Pathnames in Shell: How to Do It Correctly by tsimionescu on Tuesday June 20, 2023 @01:57AM (#36400259)
You actually indent by 2 spaces, not 4:

  Like this
4 spaces is a Markdown thing.
Re:Filenames and Pathnames in Shell: How to Do It Correctly by js2 on Tuesday June 20, 2023 @02:00PM (#36407945)
My bad, I knew that at some point. The rules are actually linked to from the well-hidden "help" at the bottom right of the comment box:

https://news.ycombinator.com/formatdoc

Re:Filenames and Pathnames in Shell: How to Do It Correctly by chasil on Monday June 19, 2023 @10:02PM (#36398853)
Re:Filenames and Pathnames in Shell: How to Do It Correctly by scbrg on Tuesday June 20, 2023 @01:31AM (#36400096)
Every time I see someone argue for case insensitivity I remember this excellent Hacker News comment on the issue: https://news.ycombinator.com/item?id=29755865

It's definitely more complex than you'd naively think it is.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by arp242 on Tuesday June 20, 2023 @02:05AM (#36400306)
People are trying to make things more complex than they are. No one said you need to convert between scripts or muck about with fullwidth variants or stuff like that; "semantically identical" is not the same as "case insensitive". That post is going off on a "if you want case-insensitivity then you must also treat color and colour as identical!" tangent, which is just silly and not what anyone has ever argued for.

The cases where case translations are more complex than a simple 1-to-1 mapping are the exception, not the rule (German, Greek, Turkish, Lithuanian). These can be dealt with.

It's certainly not the case that it "will only work for English and a few European languages"; it will work for much of the world.

The fact of the matter is, two out of the three most used systems today are case-insensitive, and Linux/POSIX being the exception is rather painful.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by lelanthran on Tuesday June 20, 2023 @06:29AM (#36402019)
> It's certainly not the case that it "will only work for English and a few European languages"; it will work for much of the world.

I respectfully disagree.

Consistently broken in the same way for everyone is better than unreliably working for some people, reliably working for other people, unreliably broken for a third group and reliably broken for a fourth group.

Filenames should be created as the user typed it - don't change the input before storing it.

Filenames should be displayed as the user typed it - don't render output different to what was input.

Tools should match filenames as the user expects it - in this case (hehe) it should perform a case-insensitive match. Ambiguity resolution has to be performed in the case where there is more than one match.

    cat > MyFile.txt    # Create 'MyFile.txt'
    ls                  # Display 'MyFile.txt'
    echo myfile*        # Display 'MyFile.txt'
    vim myfile.txt      # Opens 'MyFile.txt'
The first problem with this is in automated shell scripts: there is no interactivity so the script can't prompt the user "Which of the following files did you mean to open: [MyFile.txt, myfile.txt]?". This means that a script which relies on 'foo.txt' will fail if someone creates a 'Foo.txt' in the same directory.

Another issue with this is that userspace calls to `open()`, `stat()`, etc aren't able to fail and return a list of case-insensitive matches in the case of ambiguity. This makes handling the ambiguity the applications (very complex) problem - before any `open(fname)` call, the application will first have to `scandir()` to get all the filenames, then perform a case-insensitive match against the list to get all the CI matches, then prompt the user to select the correct one.

> The fact of the matter is, two out of the three most used systems today are case-insensitive

I think it's more that they are case-aware than case-insensitive; after all the filesystem certainly stores the case, and they both retrieve the case correctly.

It's the tooling that faces the user which "fix" cases to prevent two files with the same name in different cases being created.

You can certainly create file 'FOO' and file 'foo' on Windows in the same directory, and then the tools tend to randomly open only one of them no matter which on the user clicked on.[1]

Which is why I say that the actual filesystem is case-sensitive. The user programs normalise the case for the user.

[1] EDIT: I accidentally did this once, and had to write another small tool to remove files with the filename as typed because the normal tools (del, explorer.exe) just randomly choose one file to remove.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by Someone on Tuesday June 20, 2023 @10:25AM (#36404452)
> Filenames should be created as the user typed it - don't change the input before storing it.

I wouldn’t go that far. Certainly, I would use some normalization algorithm on whatever the user typed, so that there’s no difference between typing a precomposed character (https://en.wikipedia.org/wiki/Precomposed_character) and typing a character and a combining character (https://en.wikipedia.org/wiki/Combining_character)

If you don’t do that, the user’s keyboard layout may affect whether they can type a given file name.

Also (nitpicking), if a user types a backspace or control-H, I wouldn’t include a 0x08 in the file name.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by alextingle on Tuesday June 20, 2023 @06:38AM (#36402079)
> People are making things more complex than they are.

You are the one who wants to introduce extra complexity: A few narrow corner cases where the filesystem treats certain code-points as equivalent. Imagine how confusing that would be to someone who doesn't regularly use those code-points.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by kergonath on Tuesday June 20, 2023 @02:14AM (#36400363)
> It's definitely more complex than you'd naively think it is.

It has been working just fine on macOS for more than 20 years now.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by creshal on Tuesday June 20, 2023 @05:02AM (#36401435)
…for English, and a handful of other European languages where the problem is trivial. Not for the 70% or so of humanity who isn't European or European-descendant.
Re:Filenames and Pathnames in Shell: How to Do It Correctly by kergonath on Tuesday June 20, 2023 @07:37AM (#36402594)
It uses a specific normalisation. It’s not perfect (even for supposedly easy European languages), but that’s still many less foot guns than the status quo. Again, macOS works just fine with these languages.
Re:Filenames and Pathnames in Shell: How to Do It Correctly by creshal on Wednesday June 21, 2023 @05:08AM (#36416185)
Oh, wait, THAT'S what keeps breaking umlauts every time Mac users try to share files with any other operating system? Bloody hell, that garbage just keeps causing trouble constantly.
Re:Filenames and Pathnames in Shell: How to Do It Correctly by ElectricalUnion on Tuesday June 20, 2023 @09:47AM (#36403906)
[1] https://github.com/tesseract-ocr/tesseract/issues/3447

Less that 20 years ago. Not a small project.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by IshKebab on Tuesday June 20, 2023 @05:02AM (#36401433)
That's interesting but he does dive head first into a stupidly common fallacy - "if we can't do it perfectly we shouldn't do it at all".

I still think filesystems should be case sensitive, but not because there are some weird languages out there that it wouldn't work for.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by ykonstant on Tuesday June 20, 2023 @06:41AM (#36402102)
"weird languages"? sigh.
Re:Filenames and Pathnames in Shell: How to Do It Correctly by scbrg on Tuesday June 20, 2023 @08:41AM (#36403170)
> That's interesting but he does dive head first into a stupidly common fallacy - "if we can't do it perfectly we shouldn't do it at all".

I rather think you need to solve at least a somewhat significant subset of a problem in order to justify the extra complexity of the solution (and any confusion caused by it not solving the whole problem). Believe me, I'm a great believer in "perfect is the enemy of good", but not to the extent that I think that "any shitty solution at any cost is better than nothing". I'm not convinced that case insensitivity doesn't fall in the later category.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by IshKebab on Tuesday June 20, 2023 @09:18AM (#36403525)
Over 2bn people speak English, Spanish or French. That's somewhat significant. You're going to tell those 2bn people they can't have nice things because there are other people that wouldn't get them?

As I said before, I still don't think it is a good idea, but that's because of other reasons (basically it introduces more confusing behaviour than it removes); NOT because it can only work for a subset of people.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by scbrg on Tuesday June 20, 2023 @09:49AM (#36403926)
> Over 2bn people speak English, Spanish or French. That's somewhat significant. You're going to tell those 2bn people they can't have nice things because there are other people that wouldn't get them?

If the cost of the nice thing (which I, as one of the 2bn don't even consider nice) has to be paid by the other 6bn people as well, sure.

> As I said before, I still don't think it is a good idea, but that's because of other reasons (basically it introduces more confusing behaviour than it removes); NOT because it can only work for a subset of people.

This is my main reason for being hesitant to the whole thing as well. The post linked above just happened to broaden my view on the problem a bit.

Re:Filenames and Pathnames in Shell: How to Do It Correctly by Affric on Tuesday June 20, 2023 @01:18PM (#36407317)
100% agree that the argument should be around file system behaviour rather than some imagined social justice in file system names.

There are some weird takes on here. Most users aren’t even going to see the file system in the future.

If there were a time to make everything case insensitive it was 35 years ago.

We might even rarely type soon.