Live data from Hacker News

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

twitter.com

151–160 of 817 posts

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

#151

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.

I wish they did "User Files" instead of "Users" too, because so much software breaks on the home area having a space in it.

Not least, it makes writing scripts for various shells and getting the quoting rules right an absolute pain as well...

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

#152

Earlier quoted context omitted.

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

Imagine if they made programmers put 64 bit DLLs in a "System32" directory and 32 bit DLLs in a "SysWoW64" directory. That would really keep 'em on their toes!

You should look into the behavior of the /windows/sysnative link. It appears and disappears depending on whether your process is running as 32 bit or 64 bit.

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

#153
Yes, spaces in filenames introduce edge cases and bugs that people are not always aware of.

E.g. Here's a random StackOverflow q&a about a Git pre-commit hook where the top-voted answer does not properly handle filenames with spaces : https://stackoverflow.com/questions/2412450/git-pre-commit-h...

However, the 2nd and 3rd most upvoted answers do mention "-z" option to handle spaces.: https://stackoverflow.com/questions/2412450/git-pre-commit-h...

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

#154

I'm hardly afraid but I just think it's poor ergonomics. Same as the move from xset m 0 0 to xinput --set-prop 'pointer:Logitech USB Receiver' 'libinput Accel Profile Enabled' 0, 1 Everything seems to be going this way in Linux land. Longer names, harder to type names, camelcase names, spaces... I'm looking forward to an OS that treats command line ergonomics as a first class feature and where camelcase & spaces are…

I could infer a lot about the second and what those params mean and what they do. The first one is some magical incantation.

But which case should software interfaces optimize for? Ergonomics of someone who uses a tool frequently, or interpretability for casual by-standers of some out-of-context shell command?

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

#156

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 ':'.

If you suspect that the file might be handed to a bash script at any point, being afraid of spaces is very healthy for sure.

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

#157

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.

Laughs in C:\PROGRA~1\ (try it, still works in Windows 10)

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

#158

Earlier quoted context omitted.

And that was a good idea, if only Microsoft also fixed the CreateProcess function, Windows would be somewhat sane in this regard. But somehow nobody seemed to think of it. Seriously, look at it: https://docs.microsoft.com/en-us/windows/win32/api/processth... The arguments are a single string. So you want to pass parameters with spaces in them? You've got to add quotes and stuff all of that into a single string. Inste…

The root cause is that argv isn't a first-class citizen like on linux, but an abstraction. The kernel only cares about a single string argument. If you use main instead of WinMain, the CRT will transform the single string into an argv for you. Oh and cmd.exe uses a different escaping scheme than the CRT.

Microsoft is in full control of the Windows kernel, so they can make it care about whatever they want to, and one would think better argument passing would be a nice quality of life improvement. Less nonsense for developers to deal with, and less weird bugs on the platform.

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

#159
post #149

Earlier quoted context omitted.

I go one step further: 2021-11-11_client_project-name.ext 2021-11-11_client_projectName.ext is also OK. But underscore separates fields, hyphens for space replacement.

this is the way

but the extra Shifts, no thank you
Post reply on HN