atilaneves / reggae

Build system in D, Python, Ruby, Javascript or Lua
BSD 3-Clause "New" or "Revised" License
185 stars 22 forks source link

compile_commands.json breaks when paths contain spaces #291

Open WebFreak001 opened 6 months ago

WebFreak001 commented 6 months ago

the file property isn't really defined what exactly it holds, so it's kinda implementation defined and reggae puts multiple files in it, space separated - which would break for consumers trying to split just by spaces, because file names with spaces are not escaped.

Furthermore the commands in command are also not escaped and contain stuff like

"command": "/usr/bin/dmd -makedeps=.reggae/objs/./gdb-test.objs/GDB Test/source_app.o.dep -debug -g -w -version=Have_gdb_test '-I/home/webfreak/dev/GDB Test/source/' -of.reggae/objs/./gdb-test.objs/GDB Test/source_app.o -color=on -c /home/webfreak/dev/GDB Test/source/app.d /home/webfreak/dev/GDB Test/source/baz.d /home/webfreak/dev/GDB Test/source/scope.d /home/webfreak/dev/GDB Test/source/xd.d"

which would just break if you were to try to run them like this.

atilaneves commented 5 months ago

What would the solution be? It can't be to add backslashes before the spaces, since that wouldn't be a valid JSON string anymore.

WebFreak001 commented 5 months ago

backslash would work, quotes would work, just anything that makes the shell run the command properly when run

nordlow commented 4 months ago

As I already wrote at https://github.com/atilaneves/reggae/issues/303#issue-2314758385, some string literal escape sequences are missing an extra backslash. It might be as simple as replacing every string literal backslash with two backslashes.