5 ms·
Whenever I create a filename that is long or has spaces, I still pause and worry "okay, what might break if I do this", even though such concerns probably died
by glonq 3y ago
Whenever I create a filename that is long or has spaces, I still pause and worry "okay, what might break if I do this", even though such concerns probably died a couple decades ago.
Actually scripts breaking if files or paths have a space in them seems to be a thorn in the side of dev/ops/it folks that never goes away, does it?
- ChrisSD 3y agoOn Unix perhaps. Windows forced IT folks to deal with the issue by having folders like "Program Files". Even the user's folder used to be in "Documents and Settings" (but they backed down from that eventually and now it's just "Users").
- justsomehnguy 3y ago> but they backed down from that eventually Only because they were started to hit MAX_PATH there: C:\Users\Johnathan Aparecido da Silva\AppData\Local\ASUS\ASUS System Control Interface\AsusSoftwareManager C:\Documents and Settings\Johnathan Aparecido da Silva\AppData\Local\ASUS\ASUS System Control Interface\AsusSoftwareManager
- nomel 3y agoThe `subst` command provides an easy way around that. Link the last folder somewhere closer to the root, to make longe-than-255 paths accessible. Then, when you're done, remove the link and your files are protected from pesky things like virus/malware scanners. I used it to hide my old virus/malware collection, made from what my computer was infected with through the years.
- WirelessGigabit 3y agoTo this date one needs to be careful with executing applications and spaces in the path. For example: D:\test>dir ... 08/10/2023 09:29 AM <DIR> . 08/10/2023 09:30 AM <DIR> Foo Bar 08/10/2023 09:35 AM 79 Foo.bat ... D:\test>dir "Foo Bar" ... 08/10/2023 09:30 AM <DIR> . 08/10/2023 09:29 AM <DIR> .. 08/10/2023 09:35 AM 79 Foo.bat ... D:\test>type Foo.bat @echo off echo Executable: %0 echo Path to executable: %~dp0 echo Params: %* D:\test>type "Foo Bar\Foo.bat" @echo off echo Executable: %0 echo Path to executable: %~dp0 echo Params: %* D:\test>Foo.bat hello Executable: Foo.bat Path to executable: D:\test\ Params: hello D:\test>Foo Bar\Foo.bat hello Executable: Foo Path to executable: D:\test\ Params: Bar\Foo.bat hello D:\test>"Foo Bar\Foo.bat" hello Executable: "Foo Bar\Foo.bat" Path to executable: D:\test\Foo Bar\ Params: hello D:\test> Mess up the quotes and you're executing something one level up.
- keepamovin 3y agoNice example!
- ChrisSD 3y agoRight, but my point is that "Program Files" &co were so common that it forced IT people (and everybody else) to handle this correctly. Executing something one level up is not the kind of bug that's going to be unnoticed when it'll be hit so often. (btw most IT folks prefer powershell, if only because all the management tools are powershell modules)
- xp84 3y agoThis was actually genius, though it was/is so annoying typing these verbose paths
- keepamovin 3y agoAgree. Those short abbreviations have a kind of crunchy sonic quality when you say them that’s satisfying.
- Anthony-G 3y agoUnix shell scripts will break when filenames/paths have spaces if variable expansions are not quoted, resulting in word splitting and filename expansion (globbing). This is something that is drilled into learners by all good teachers, e.g., https://mywiki.wooledge.org/Quotes#When_Should_You_Quote.3F https://mywiki.wooledge.org/Quotes#When_Should_You_Quote.3F
- nomel 3y agoWait until you hear about `make`, completely cementing the idea of '_' as space for decades to come [1]! Related, any time I join a new group, that uses bash in any capacity, I introduce them all to the `shellcheck` utility [2], and run a shell script of the person with the largest ego through, as a "demo". [1] https://stackoverflow.com/a/9838604/1487072 https://stackoverflow.com/a/9838604/1487072 [2] Online version: https://www.shellcheck.net/ https://www.shellcheck.net/
- keepamovin 3y agoAwesome! Thanks for introducing me to this. I mean my ego ha