Live data from Hacker News

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

twitter.com

121–130 of 817 posts

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

#122

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…

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.

And yet they introduced C:\ProgramData in later versions.

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

#124

Still way too many libraries and programs can't handle spaces in filenames. And shells and other programs still have problems with perfectly legal characters in filenames too, like '!' or ':'.

yep, I still don't use spaces. I also don't use uppercase characters. Just underscores or hyphens.

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

#126
post #22

This is a UI/UX problem that I only face when dealing with shells and shell scripts. Never had any issues when spawning processes from within languages/runtimes that support sane argument arrays. sh , bash and cmd.exe are shit. The shell needs serious rethinking.

I see that there are lots of comments about problems of TAB-completions with filenames with spaces in this comment section and I am frankly puzzled: both Bash and cmd.exe actually TAB-complete those perfectly fine, inserting quoting where it's needed.

And where it isn't needed. If you have a path that contains a variable and a space, bash will happily escape the $, making the path invalid. See the following:

  $ cd $HOME
  $ mkdir my\ dir
  $ ls my[tab]
  $ cd /
  $ ls $HOME/my[tab]
  ls: cannot access '$HOME/my dir/': No such file or directory
That error is because when you press [tab], bash changed the path to \$HOME/my\ dir/ but that isn't obvious from the output and I couldn't find a proper way to include the tab-expanded result in the transcript.

(edit: this is on GNU bash, version 4.3.48(1)-release but I've seen this behaviour for years)

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

#127
post #44

One of the main reasons why Windows used "Program Files" and "Documents and Settings" was to force the programs (and programmers) to deal with paths with spaces. And you know, for the most part it kinda, more or less worked out although of course even today you will find programs that ask you to install them in a folder without spaces in the path.

The main culprit for space issues is stuff relying on BAT or CMD files, where escaping variables seems to be a black art. Sadly such set includes loads of Java programs. If only SUN had shipped a standard way to generate isolated exe files in 1998... but they worked under the presumption that you'd have a JVM already there, because distributing that monster was difficult in dialup times, so you could just hand people…

> The main culprit for space issues is stuff relying on BAT or CMD files, where escaping variables seems to be a black art.

Actually it isn't, just use double quotes and add a '~'. It's just about the only thing batch files handle better than shell scripts. set "VARIABLE=%~PATH"

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

#128

I am also that age, and kebab-case is the best case for filenames. 2021-01-01-some-important-document.pdf gives me the warm fuzzies. On the off chance that some more differentiation is needed, throw in an underscore and a whole new world opens up

Kebab case is the often overlooked benefit of prefix notation and semantic white space in programming languages. Honestly the best case of all cases imo.

One glorious day we'll accept programming languages that require spaces around infix arithmetic operators so that we can make kebab case a reality!

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

#129

Still way too many libraries and programs can't handle spaces in filenames. And shells and other programs still have problems with perfectly legal characters in filenames too, like '!' or ':'.

yep, I still don't use spaces. I also don't use uppercase characters. Just underscores or hyphens.

Sometimes I break the rule and use uppercase but never spaces.

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

#130

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 tip2: Use std lib path processing utilities
Post reply on HN