Live data from Hacker News

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

twitter.com

671–680 of 817 posts

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

#671

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…

> anything with subprocesses

I'm begging software developers to stop using subprocess APIs that take a string argument (system(), child_process.exec(), Process.Start(string)) and start using subprocess APIs that take an array of arguments (execvp(), child_process.execFile(), Process.Start(string, IEnumerable).)

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

#672

Earlier quoted context omitted.

Seems like MS had the same idea according to an answer in the link: > Microsoft intentionally made programs install to C:\Program Files on Windows 95+ to force programmers to deal with spaces in filenames.

On the other hand their case sensitivity behaviour means that “cross-platform” Java applications can break if they are run on a non-windows platform where opening files is case sensitive (unlike on windows)

It's actually a feature.

Easier to add a flag to ignore case rather than fix bugs where files only differ by case and are therefore overwritten on a case-insensitive filesystem.

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

#673

Earlier quoted context omitted.

Better solution: only allow ASCII, maybe dashes, and up to twelve characters. Problem solved. Enforce this in LDAP. Strict convention is better than flexibility and predicting obscure edge cases that can fail.

only allow ASCII, maybe dashes, and up to twelve characters. Problem solved ...and only hire people from the exact same background as you, who will never have unusual characters or accents in their name. And also make sure not to have any users who aren't exactly like you, and conform to this very narrow requirement. Surely, excluding 90% of the world won't hurt revenue in any way.

You can use an "ASCII-fied" version of the name, only ~27% of mine can be typed in ASCII letters that look similar but the rest is just phonetically or visually close-enough letters. This is something people did for decades and nowadays even government IDs have an ASCII-fied (well, Latin-fied) version of the name.

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

#674

Reminds me of the time I watched a coworker's head explode when he tried to extract an archive (from a 'Nix environment) on his Windows machine and was indignant about getting duplicate filename errors.

As a Windows guy case still seems like a weird thing to worry about.

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

#675
post #411

I have an overly-aggressive function in my .bashrc to rename all files in the current directory: # Rename all files in a directory rn() { rename "s/ /-/g" * rename "s/_/-/g" * rename "s/–/-/g" * rename "s/://g" * rename "s/\(//g" * rename "s/\)//g" * rename "s/\[//g" * rename "s/\]//g" * rename 's/"//g' * rename "s/'//g" * rename "s/,//g" * rename "y/A-Z/a-z/" * rename "s/---/--/g" * rename "s/-‎--/--/g" * } I use th…

If you're a developer you're doing yourself a big disservice by not learning how to deal with special characters.

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

#676

Earlier quoted context omitted.

Surely you must run into conflicts now and then?

That's the most beautiful part! After running this script there are no more conflicts, because it just silently overwrites all but one version of the "cleaned" filename. (Also—that entire function is super inefficient and could be replaced with a single invocation of "rename".)

Totally inefficient. But for me it's readable and practical. This is mostly just a convenience function for me to help store files in a format I like rather than something I need optimized. If it ever started to feel slow, sure I could optimize. But for now, when I still occasionally download a file that has some weird character and I just prefer to add another line to my function.

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

#677
post #162

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…

> Pro tip: rename your development directory (or even better: the workspace path in CI) to put a space and/or special characters in it. A former co-worker changed his name in our auth system to include an apostrophe, so that whenever we handled names wrong he'd find it.

Obligatory xkcd https://xkcd.com/327/

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

#678
post #675
post #411

I have an overly-aggressive function in my .bashrc to rename all files in the current directory: # Rename all files in a directory rn() { rename "s/ /-/g" * rename "s/_/-/g" * rename "s/–/-/g" * rename "s/://g" * rename "s/\(//g" * rename "s/\)//g" * rename "s/\[//g" * rename "s/\]//g" * rename 's/"//g' * rename "s/'//g" * rename "s/,//g" * rename "y/A-Z/a-z/" * rename "s/---/--/g" * rename "s/-‎--/--/g" * } I use th…

If you're a developer you're doing yourself a big disservice by not learning how to deal with special characters.

I agree. I am a developer and I know how to deal with special characters. But this isn't something I use professionally. I just prefer not to have to deal with special characters in the pdfs, m4as, txts, and other files that I use on a daily basis. When I write papers, I'll write ū or Ñ or ç or whatever (incidentally, I have a lot of shortcuts in my .vimrc for those). I would not say I am "afraid" to use spaces in filenames, but I get a certain satisfaction storing academic papers in the author--paper-title.pdf format and my notes in author--paper-title.md because it helps me find things.

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

#679
post #516

Earlier quoted context omitted.

You’re clearly a more capable user than me, but even so, take care. The time I accidentally moved /etc has scarred me for life.

Early on in my Linux-using-life I made the mistake of deleting /etc. That was a learning experience like no other :)

A couple of weeks after moving to UNIX from MSDOS, I thought I'd remove lots of unnecessary 'dot-directories' from the /tmp directory. I was root as I had no concept of being a 'normal user'.

So I ran two simple commands:

     cd /tmp
     rm -fr .*
and wondered why it was taking so long.

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

#680

I'm not young, but I've been using Macintosh computers regularly since 1990, and even back then file names could be up to 31 characters long, and could include any character except colon.¹ So I'm pretty comfortable using spaces, and sometimes even non-ASCII characters, in file names. Also back then Mac file names typically did not include an extension, because the file's type was stored as part of the metadata in its…

All of that was very cool and impressive and extremely user-friendly. However, I found the lack of a command-line to be restricting.

On the other hand Mac had some great GUI programs.

Sometimes i think that the command-line is a crutch that keeps programmers from learning how to make good UIs.

Post reply on HN