Live data from Hacker News

I'm “still afraid to use spaces in file names” years old

twitter.com

641–650 of 817 posts

Re: I'm “still afraid to use spaces in file names” years old

#641
post #145

I have an uneasy feeling whenever I see a path parameter declared as string. Path is not a string - it's a sequence of path components and should be treated as such by our APIs. A path should be parsed once - on user input - and then used in its "sequence form" throughout the software stack. And "path component" is not an arbitrary string either - e.g. appending a path component to the path should first require conve…

"Path is not a string - it's a sequence of path components and should be treated as such by our APIs." For maximum correctness, you want to turn it into a file handle as soon as possible, and do all operations through the variations of the file functions that end in "at", like: https://linux.die.net/man/2/openat The downside of this approach is that you still technically have to carry the path around with you if you…

doesn't this lock the file?

Re: I'm “still afraid to use spaces in file names” years old

#644
post #569
post #453

Earlier quoted context omitted.

Oh, my young friend, you have no idea what POSIX has done to you. "While no one sane would put newlines in directory names, such corruption of the results could lead to exploitable vulnerabilities in scripts." http://www.etalabs.net/sh_tricks.html

He he. Want to see true craziness? POSIX file names are just a bag of bytes. They don't even have to be text, they can be anything (almost), there's no standard text encoding: https://lwn.net/Articles/325304/ And in typical Open Source fashion, someone actually claims it's a feature: https://lwn.net/Articles/325398/ because hey, you 99.999% percenters can suffer so that I, 0.001% percenter can implement my wacky syst…

This appears to demonstrate the full range of abuse.

    $ mkdir hold
    $ cd hold

    $ cat ../wildname.c 
    #include 
    int main(int argc, char **argv)
    { char n[256]; int i,j=0; FILE *fp;

      for(i=1; i? 
 
 
 @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

    -rwxr-xr-x. 1 luser lgroup 8464 Nov 11 16:32 a.out
Just because you can do something does not mean that you should.

Re: I'm “still afraid to use spaces in file names” years old

#646
post #610

Earlier quoted context omitted.

Good news, we have solutions. You could use continuous integration and software containers like Docker.

Does Docker abstract filesystem behaviors like this? I always thought that it stopped at the libc level - that is, libc is included in the container, but it calls the host kernel's system calls, and so inherits the host kernel's behavior (including things like underlying filesystem case sensitivity).

[deleted]

Re: I'm “still afraid to use spaces in file names” years old

#648

Earlier quoted context omitted.

GoboLinux symlinks everything into an FHS-ish structure under /System/Index/ so you still have a single place where binaries/libraries/includes/etc. live. (There are also symlinks from /usr/lib, /usr/bin, and others into /System/Index/ for compatibility with programs where those might be hardcoded.)

That actually seems like some low hanging fruit to go on a commit spree correcting code that hard codes paths

It is low hanging fruit as far as the software is concerned. Simply parameterize all paths.

Will upstream accept such patches though? Sounds unlikely to me.

Re: I'm “still afraid to use spaces in file names” years old

#649

I work on a complex desktop application, and it's been astounding the number of bugs that have appeared over the years triggered by spaces and other unusual characters in file names. If you do anything with subprocesses or path processing, it's absurdly easy to hit in a thousand different ways, over and over again. Pro tip: rename your development directory (or even better: the workspace path in CI) to put a space an…

In that case, be thorough and insert a Chinese and an Arabic character to enforce a Unicode check.

Re: I'm “still afraid to use spaces in file names” years old

#650
post #320

Earlier quoted context omitted.

Behold! https://en.m.wikipedia.org/wiki/Filesystem_Hierarchy_Standar...

Yeah, except that tells me nothing useful... The question is exactly the same: So where do I install this random binary I downloaded from the internet or compiled myself? Is it /opt, /usr/bin, /usr/local/bin, or /bin? Where do I put the dependencies I compiled for this software - /usr/lib, /usr/local/lib, /lib, /opt/lib, /opt/ /lib, or what?

> So where do I install this random binary I downloaded from the internet or compiled myself?

In your home directory.

Post reply on HN