8 ms·
As a related anecdote, you NEVER want to put whitespace in filepaths. Ever. Tons of programs will just break, even in 2023, even Microsoft ones (looking at you
by nicetryguy 3y ago
As a related anecdote, you NEVER want to put whitespace in filepaths. Ever. Tons of programs will just break, even in 2023, even Microsoft ones (looking at you Powershell), and i'd imagine forevermore.
Your life will end up as a series of awful MYPATH~1\ kludges. You have been warned.
EDIT: There seems to be different camps here and perhaps a generational divide. Maybe the kids haven't (or never will be) burned with this one, but i've seen too much, wasted too many hours, wrote too many workarounds, and will forever remain #TeamNoWhiteSpace.
- eru 3y agoTools in the Unix world aren't too robust in that regard either. Gnu Make is particularly egregious.
- Joker_vD 3y agoThere is also gnu patch: the filenames in the unified patch file format can't contain spaces and can't be quoted so... just don't use spaces, I guess.
- mdaniel 3y agohow old is your copy of patch? $ cat > my.patch <<PATCH diff --git a/alpha beta/charlie b/alpha beta/charlie new file mode 100644 index 0000000..3b18e51 --- /dev/null +++ b/alpha beta/charlie @@ -0,0 +1 @@ +hello world PATCH $ patch -p1 < my.patch patching file 'alpha beta/charlie' $ patch --version GNU patch 2.7.6
- dr-detroit 3y ago[dead]
- ygra 3y agoCurious about PowerShell misbehaving there. Care to share any details? Typically you never want to handle paths to files as strings, or at least resolve them to File/DirectoryInfo objects as soon as possible. But the only real blunder regarding paths in PowerShell I'm aware of is the Path parameter to various cmdlets and having [] in file names (which is why LiteralPath always exists alongside Path parameters).
- nicetryguy 3y ago$args[x] breaks. Get-Content breaks. probably more. ...admittedly i'm not the best with Powershell. There are probably workarounds or things that i did wrong.
- justeleblanc 3y agoJust put them in quotes. PowerShell is infinitely better than bash/zsh/... at handling spaces. You're spreading nonsense.
- nicetryguy 3y ago> Just use quotes bro Man, it's never that simple. How about generating Powershell scripts with quotes? Sometimes you are dealing with escape characters \", sometimes you aren't. Why bother with all that? Hell, versions of software and compilers change such behaviors either on purpose or by accident all the time. It just gets messy dude. C:\NEVER_~1\AGAIN_~1.NOP Perhaps i'm a dinosaur still scarred by the golden olden days, but, there is no convincing me that whitespace in filenames or URLs is ever a good idea.
- justeleblanc 3y agoI don't know what to tell you. You gave two examples that aren't actually issues. But if there's no convincing you, I won't bother. Have a nice day.
- nicetryguy 3y ago> You gave two examples that aren't actually issues. Man, i've had config files break because i saved them in UTF-8 instead of ANSI. I hope to god you never have to experience the horror... You also have a nice day.
- justeleblanc 3y agoThis is getting less and less relevant.
- dmd 3y agoCounterpoint: Nearly all of my (thousands of) users use whitespace in basically every single folder name and file name every single day (which are usually titles of papers or experiments), and none of them ever have any problems. When writing software I always make sure that all my test data has spaces - and not just the normal one but weird unicode ones too - in paths and filenames.
- numpad0 3y agoNon-ASCII characters too, if situation allows. Lots of apps aren’t tested to work with that whatever “new” API.
- jeroenhd 3y agoI know someone with an é in his name. He once made the mistake of using that character in his username. Windows broke. Programs broke. The registry broke. Special characters work well enough, but never use them in standard directory paths. If you want your folder to be written correctly in your own language, you can use desktop.ini to correct the name of the folder in Windows Explorer: [.ShellClassInfo] LocalizedResourceName=Fàñćŷ Näm̀é Put that into a desktop.ini file, assign it the right attributes (`attrib +S +H desktop.ini`) and your folder will look right in any program that uses the shell API without any risk of breaking programs.
- NikolaNovak 3y agoThis is a fascinating weekly topic for me :-) I grew up in days of DOS 3 and onward, so I am basically physically incapable of using whitespace in filenames. And frequently I'll replace white spaces with underscores on files shared with me. Fascinatingly though (and sometimes irritatingly), several of my mentors have cautioned me to drop this habit as I get promoted. At management level, they all use white space and dots haphazardly, and they apparently perceive underscored filenames negatively. This goes up drastically at executive level.
- eru 3y agoInteresting observation. I can exactly see where the low status comes from.
- Joker_vD 3y agoThat's... definitely not as dramatic as you try to make it sound. "Program Files" and "Documents and Settings" have been around for almost three decades, and most programs work just fine with files living somewhere inside those paths.
- mynameisvlad 3y agoI mean, let’s go past “Program Files” to “Program Files (x86)” which has both spaces and special characters, and which was moved from the former. And most programs are able to handle that just fine.
- mdaniel 3y agoAnd the "cherry on top" is there's an env-var named `%ProgramFiles(x86)%` (aka `${env:ProgramFiles(x86)}` in PS) that points to where that directory actually lives since AFAIK it's controlled by a registry entry
- Zecc 3y agoSure, but that's because everyone uses SHGetFolderPath or Environment.GetFolderPath to get these paths instead of hardcoding them. Right? Right??
- wvenable 3y agoMicrosoft called the directory where programs are installed "Program Files" and documents in "My Documents" specifically so that developers would have to learn to deal with spaces immediately.
- mynameisvlad 3y ago> maybe the kids Really? You posted a divisive and absolute statement and people pointed out how it's not accurate. Considering "Program Files", a very common Windows path, was introduced back in Windows 95 (https://devblogs.microsoft.com/oldnewthing/20120307-00/?p=8153 https://devblogs.microsoft.com/oldnewthing/20120307-00/?p=81...), almost 30 years ago, it's pretty hard to blame it on "the kids". That doesn't sound like "those damn kids and their newfangled apps that can handle spaces, they'll never know the pain I went through!!!" and more like "I said something that was clearly not accurate and people pushed back". The whole thing reeks of https://www.mouser.com/blog/Portals/11/mrb-singularity-f1.png https://www.mouser.com/blog/Portals/11/mrb-singularity-f1.pn...
- nicetryguy 3y agoI've had lots of programs, libraries and scripts freak out from having whitespace in a file path. > I said something that was clearly not accurate and people pushed back Is my life experience invalid? It's a needless error that i never want to deal with again. I cover my mouth when i cough, i use my turn signal when changing lanes, and i don't put whitespace in a filepath or a URL. It's that simple. What i cannot fathom for the life of me, on HN of all places, is vehemently defending a practice that is not guaranteed to work 100% of the time: "Well iiiive never grazed an oven coil pulling a potroast out of the oven so obviously this guy is an idiot for advocating oven mitts." Give me a break dude.
- mynameisvlad 3y agoIt’s almost as if, get this, it’s not a problem, let alone anywhere even remotely in the vicinity of a problem of the scale and magnitude you claim it to be. It’s almost as if people in 2023 get by fine with spaces in their filenames whereas you seem to be stuck squarely in the 1980s. I know, it’s a crazy idea. Those kids and their insanity. /s
- nicetryguy 3y ago> you seem to be stuck squarely in the 1980s. You know, my main hobby is writing ASM for classic video game consoles, and my opinions and experience involves lots of janky / homemade / antiquated programs, so honestly you're not wrong =p
- nicetryguy 3y agoEDIT2: IT JUST HAPPENED AGAIN trying to add a Windows Environment Variable in Program Files from Visual Studio 2022. UGH!!!! Feast your eyes on this abomination doubters: C:\PROGRA~1\MICROS~4\2022\COMMUN~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\ml64.exe This is using a Microsoft development program with a Windows Environment Variable, mind you...