Building System doesn't work case there are space or special characters in the directory name
Petro reported that IDF didn't work inside his Mac "/Volumes/Macintosh HD (CS)/" then I suspected of spaces in the name of Volume name and then I decided to test similar thing on NuttX building system:
alan@dev:/tmp/New Space NuttX/nuttx$ ./tools/configure.sh sim:nsh ./tools/configure.sh: line 137: [: too many arguments ./tools/configure.sh: line 156: [: too many arguments ./tools/configure.sh: line 176: [: too many arguments ./tools/configure.sh: line 181: [: too many arguments grep: /tmp/New: No such file or directory grep: Space: No such file or directory grep: NuttX/nuttx/tools/../boards///sim/configs/nsh/defconfig: No such file or directory grep: /tmp/New: No such file or directory grep: Space: No such file or directory grep: NuttX/nuttx/tools/../boards///sim/configs/nsh/defconfig: No such file or directory Copy files install: target '/tmp/New Space NuttX/nuttx/tools/../Make.defs' is not a directory Failed to copy /tmp/New Space NuttX/nuttx/tools/../boards///sim/configs/nsh/Make.defs
Having built NuttX a lot, I've had to deal with this often. Spaces in files and directory names are typical in the Windows environment. It is not unusual at all.
The culprit is bash and how it breaks things up to form the argc/argv of the invoked processes. Here some ways that I have dealt with it:
-
Enclose the path in quotes: Like "/tmp/New Space NuttX". That only works for local changes since bash peels off one set of quotes each time that the path appears on the bash command line. So it does not work for pass file names that are passed around. Look at the breakage that was done to the Cygwin build in #3799. That STILL has not been fixed.
-
Quote the spaces with a backslash like: /tmp/New\ Space\ NuttX. I have done that with sed like:
newpath = `echo $oldpath | sed -e "s/ /\ /g"
-
Use a symbolic link:
ln -s "/tmp/New Space NuttX/" /tmp/NuttXSpace
-
Maybe tools/configure.c is more robust and can do the configuration without passing things onto the bash command line so often.
-
Just make it a documented rule that you cannot use paths that have spaces in them. But that rule makes no since in the Windows environment where paths like "Program Files (x86)" are common place. NOTE that in that case the parentheses also need to be quoted in some fashion. So sweeping the issue under the rug is probably not an option.
Yes, maybe it is better to let configure.c to take care of it, instead of using bash, this way it also could work better among OSes that doesn't support bash.