[xcodegen] Stop at shell operator in parseKnownCommandOnly

We're dealing with a potentially arbitary shell command here, so make
sure we don't continue parsing after a shell operator such as `&&`.
This commit is contained in:
Hamish Knight
2025-05-07 13:48:45 +01:00
parent 71d367a7d9
commit 8503ce0604
2 changed files with 54 additions and 10 deletions

View File

@@ -54,6 +54,31 @@ class CompileCommandsTests: XCTestCase {
knownCommandOnly: true
)
for op in ["&&", "||", ">", "<", ">>", ";", "(", ")"] {
assertParse(
"x y x/y/clang -DX -I \(op) ignored",
executable: "x/y/clang",
args: [.option(.D, spacing: .unspaced, value: "X"), .flag(.I)],
knownCommandOnly: true
)
assertParse(
"x y x/y/clang -DX -I x\(op) ignored",
executable: "x/y/clang",
args: [
.option(.D, spacing: .unspaced, value: "X"),
.option(.I, spacing: .spaced, value: "x")
],
knownCommandOnly: true
)
}
assertParse(
#"x/y/clang \< x\< "<""#,
executable: "x/y/clang",
args: [.value("<"), .value("x<"), .value("<")],
knownCommandOnly: true
)
assertParse(
"clang -DX -I",
args: [.option(.D, spacing: .unspaced, value: "X"), .flag(.I)]