mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
fix(core) exec policy parsing 2
This commit is contained in:
@@ -128,6 +128,9 @@ pub fn parse_shell_lc_single_command_prefix(command: &[String]) -> Option<Vec<St
|
|||||||
if root.has_error() {
|
if root.has_error() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
if !has_named_descendant_kind(root, "heredoc_redirect") {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let command_node = find_single_command_node(root)?;
|
let command_node = find_single_command_node(root)?;
|
||||||
parse_heredoc_command_words(command_node, script)
|
parse_heredoc_command_words(command_node, script)
|
||||||
@@ -265,6 +268,20 @@ fn find_single_command_node(root: Node<'_>) -> Option<Node<'_>> {
|
|||||||
single_command
|
single_command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn has_named_descendant_kind(node: Node<'_>, kind: &str) -> bool {
|
||||||
|
let mut stack = vec![node];
|
||||||
|
while let Some(current) = stack.pop() {
|
||||||
|
if current.kind() == kind {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let mut cursor = current.walk();
|
||||||
|
for child in current.named_children(&mut cursor) {
|
||||||
|
stack.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_double_quoted_string(node: Node, src: &str) -> Option<String> {
|
fn parse_double_quoted_string(node: Node, src: &str) -> Option<String> {
|
||||||
if node.kind() != "string" {
|
if node.kind() != "string" {
|
||||||
return None;
|
return None;
|
||||||
|
|||||||
Reference in New Issue
Block a user