4 ms·
It is very easy to write a bash script that completely mishandles variables containing filenames with spaces, for example: cp ${FILENAME} /tmp Here you should
by RayDonnelly 9y ago
It is very easy to write a bash script that completely mishandles variables containing filenames with spaces, for example:
cp ${FILENAME} /tmp
Here you should have done:
cp "${FILENAME}" /tmp
Also, GNU make, still one of the cornerstones of building C and C++ libraries (since CMake and Autotools most commonly use that backend) cannot handle spaces in paths at all well.
- JoBrad 9y agoThat’s a problem with those tools that, frankly, should have been addressed long ago. There are ways for script creators to deal with spacing in names, but spaces have been supported for decades now, on every OS, so it’s silly that the tools we use every day act like they don’t exist.
- RayDonnelly 9y agoWhile I agree with what you have said, as creators of a software distribution bundling software and a build system to build more software it would be remiss of us not to warn people when they try to install said software into a path containing spaces. Though as @kalefranz said already, we do allow it on Windows, we just warn loudly.
- type0 9y agoAlso as far as I remember Windows doesn't distinguish between capital and lower case letter in file paths
- RayDonnelly 9y agoYes it does. By default it is case-preserving, case-insensitive but there is a registry key to enable case-sensitivity. https://superuser.com/q/266110 https://superuser.com/q/266110
- type0 9y agoThanks.
- tyingq 9y agoThat's a problem with the shell, not the tools. The shell is deciding whether something is one arg or more, and passing the arg list to the tools.
- RayDonnelly 9y agoIt is also an unavoidable problem with GNU make and an easy to make mistake when writing CMake files. These tools should have required quoting up-front so filenames are never seen without them but it's a bit late in the day now to suggest fixing this.
- JoBrad 9y agoI'd include the shell as one of the tools we use on a regular basis. If I use a command like scp with wildcards in the input path, and the files that are returned contain colons, for example[0], the fact that the shell doesn't quote every file with a space or colon in its name before passing it off to scp is a deficiency in the shell, which gets reflected when scp refuses to copy it. [0] https://stackoverflow.com/questions/14718720/how-can-i-scp-a-file-with-a-colon-in-the-file-name https://stackoverflow.com/questions/14718720/how-can-i-scp-a...
- rusk 9y ago"if ifs and buts were candy and nuts, we'd all have a merry Christmas"