Live data from Hacker News

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

twitter.com

511–520 of 817 posts

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

#511
post #408

Earlier quoted context omitted.

All win32 functions that accept or return strings come in two varieties, with A and W suffixes, MessageBoxA/MessageBoxW. The A works with the system default 8-bit encoding (cp1251 in case of Cyrillic), the W works with unicode in wide chars. There shouldn't be much of a problem with string handling if you stick exclusively with W functions.

Using the W functions has been the advice from Microsoft's documentation for ages. But people still use the A functions because they're easier, especially when writing cross-platform software since Windows is the only major OS that made the unfortunate choice of having the base character type 16 bits wide. Fortunately the future of the Windows API does look better since Microsoft has now added proper UTF-8 support si…

> since Windows is the only major OS that made the unfortunate choice of having the base character type 16 bits wide

Apple OSes use something they call "unichar" inside NSStrings. I'm not 100% sure what it is, but it feels like it's the same 16-bit wide character.

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

#513

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.

Another interpretation is:

On the first, you think you know what it does, but you're not sure. So maybe it gets looked up.

On the second, you know you don't know what it does. You so know to look it up.

Personally, I'll take the second. Assumptions during debugging are dangerous things.

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

#515
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…

I use this snippet, to change spaces to underscore for directories and files in the current directory and below. Haven't made it a function yet, but should. I got it from stack overflow or somewhere, but no attribution. Thanks to whoever did it first:

   find . -depth -name '* *' | while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done

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

#516
post #214

Earlier quoted context omitted.

Wow, thanks for the reply, nice find! I did some poking around on my Linux system and even re-arranging the home folder was a task of its own because the system kept trying to replace folders in their original places. I will do some digging in to Gobo and see how they're handling this. Thanks again for pointing this out.

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 :)

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

#518

Earlier quoted context omitted.

On POSIX systems file names are not strings, they are sequences of bytes. They might not be UTF-8 or have any meaning. Python3 had to hack around this, they thought they could force everything to Unicode and discovered that doesn't work.

Which makes for fun issues like there's no standard way to display a filename in Unix. A system that's, you know, all about files.

That's probably because paths aren't properties of the file itself, they're helpers to reference the file.

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

#519

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.

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

If you have a username with your full name (plus point if you have special characters in your name), you will get the whole deal with shitty programs. I’m not sure if it’s me, but there were cases I simply could not use a program installed in such a location, to the point where at my previous (admittedly shitty) workplace, we often installed software in a root location…

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

#520

Earlier quoted context omitted.

> the system kept trying to replace folders in their original places. This is the file that you want: $ cat ~/.config/user-dirs.dirs XDG_DESKTOP_DIR="$HOME/" XDG_DOWNLOAD_DIR="$HOME/Downloads" XDG_TEMPLATES_DIR="$HOME/" XDG_PUBLICSHARE_DIR="$HOME/" XDG_DOCUMENTS_DIR="$HOME/" XDG_MUSIC_DIR="$HOME/" XDG_PICTURES_DIR="$HOME/" XDG_VIDEOS_DIR="$HOME/"

That helps, but be warned that there are still programs running around that just hardcode their paths

Cries in nixpkgs

(Anyone who tried to package a program that hardcodes the “usual” binary paths know the pain)

Post reply on HN