Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle quotes and spaces in the command line #1401

Open
cadmic opened this issue Dec 30, 2024 · 3 comments
Open

Handle quotes and spaces in the command line #1401

cadmic opened this issue Dec 30, 2024 · 3 comments

Comments

@cadmic
Copy link
Contributor

cadmic commented Dec 30, 2024

Describe the bug
Can't pass command line arguments containing quotes or spaces

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://decomp.me/scratch/OxjGT
  2. Click on Problems
  3. See error: Compiler error: mips-linux-gcc: cannot specify -o with -c or -S and multiple compilations

Expected behavior
Code compiles

Scratches
https://decomp.me/scratch/OxjGT

Additional context
I'm not sure if this is a bug or feature request, but I can't find a way to define a string literal for the C preprocessor (with or without spaces). This is used in OoT so currently you have to manually remove the defines from the command line in all new scratches.

@cadmic
Copy link
Contributor Author

cadmic commented Jan 3, 2025

Alright I have no idea how to do this. I want to define a string literal with CPP like '-DFOO="hello world"' or -DFOO="\"hello world\"", but the compiler flags are expanded with bash like gcc $COMPILER_FLAGS which does word splitting on spaces but no quote processing. From https://superuser.com/questions/1529226/get-bash-to-respect-quotes-when-word-splitting-subshell-output it seems like there's no way to respect quotes without eval (or something equivalent to it, like constructing a bash command in Python)

@ethteck
Copy link
Member

ethteck commented Jan 3, 2025

We also do a ton of postprocessing to whatever the compiler command field contains, so keep that in mind. sorry I don't have more useful input at the moment though

@cadmic
Copy link
Contributor Author

cadmic commented Jan 3, 2025

That's all fine, but ultimately the compiler is invoked via bash, whose word-splitting does not respect quotes. So the only way I can see to implement this is if the commands in compilers.py are not specified as a bash script, but that seems like a pretty big change. I can work around this by adding an ifeq ($(PERMUTER),) in our Makefile to not add the string literals to the command line

@cadmic cadmic changed the title [BUG] Quotes and spaces are not handled in the command line Handle quotes and spaces in the command line Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants