-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[llvm-config] Add new flag --quote-paths to optionally quote and escape paths
#103397
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
Conversation
| bool QuotePaths = false; | ||
| for (int i = 1; i != argc; ++i) { | ||
| if (StringRef(argv[i]) == "--quote-paths") { | ||
| QuotePaths = true; | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do something like:
| bool QuotePaths = false; | |
| for (int i = 1; i != argc; ++i) { | |
| if (StringRef(argv[i]) == "--quote-paths") { | |
| QuotePaths = true; | |
| break; | |
| } | |
| } | |
| bool QuotePaths = std::any_of(&argv[0], &argv[argc], [](const char *arg) { | |
| return StringRef(arg) == "--quote-paths"; | |
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As suggested.
|
I am getting back on some of my older PRs. Any objections in landing this? +@rnk |
rnk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the ping!
|
Hi, thanks for the work, looks great! As a food for thought regarding For us at Hylo, it works great though, see my script for generating a pkg-config file for LLVM: https://github.com/hylo-lang/get-llvm/blob/main/src/get-llvm.ts#L305 |
If any of the printed paths by llvm-config contains quotes, spaces, backslashes or dollar sign characters, these paths can be quoted if using --quote-paths and the corresponding characters will be escaped. Following discussion in llvm#76304 Fixes llvm#28117
49cef79 to
159409b
Compare
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
This is a follow-up for llvm/llvm-project#103397
…cape paths (llvm#103397) If any of the printed paths by llvm-config contain quotes, spaces, backslashes or dollar sign characters, these paths will be quoted and escaped, but only if using `--quote-paths`. The previous behavior is retained for compatibility and `--quote-paths` is there to acknowledge the migration to the new behavior. Following discussion in llvm#76304 Fixes llvm#28117 Superseeds llvm#97305 I could also do what @tothambrus11 suggests in llvm#97305 (comment) but that makes all Windows paths quoted & escaped since they all contain backslashes.
This is a follow-up for llvm#103397
…cape paths (llvm#103397) If any of the printed paths by llvm-config contain quotes, spaces, backslashes or dollar sign characters, these paths will be quoted and escaped, but only if using `--quote-paths`. The previous behavior is retained for compatibility and `--quote-paths` is there to acknowledge the migration to the new behavior. Following discussion in llvm#76304 Fixes llvm#28117 Superseeds llvm#97305 I could also do what @tothambrus11 suggests in llvm#97305 (comment) but that makes all Windows paths quoted & escaped since they all contain backslashes.
This is a follow-up for llvm#103397
If any of the printed paths by llvm-config contain quotes, spaces, backslashes or dollar sign characters, these paths will be quoted and escaped, but only if using
--quote-paths. The previous behavior is retained for compatibility and--quote-pathsis there to acknowledge the migration to the new behavior.Following discussion in #76304
Fixes #28117
Superseeds #97305
I could also do what @tothambrus11 suggests in #97305 (comment) but that makes all Windows paths quoted & escaped since they all contain backslashes.