Ignore '@' returned from interpolation evaluation (#636)

Only process literal `@` characters outside of interpolation evaluation.
This commit is contained in:
Richard Berry 2020-06-09 23:16:05 +01:00 committed by GitHub
parent 2a9c29c18f
commit 89ee05227b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 1 deletions

View File

@ -24,4 +24,11 @@ impl<'src> Line<'src> {
_ => false, _ => false,
} }
} }
pub(crate) fn is_quiet(&self) -> bool {
match self.fragments.first() {
Some(Fragment::Text { token }) => token.lexeme().starts_with('@'),
_ => false,
}
}
} }

View File

@ -206,6 +206,7 @@ impl<'src, D> Recipe<'src, D> {
} }
let mut evaluated = String::new(); let mut evaluated = String::new();
let mut continued = false; let mut continued = false;
let quiet_command = lines.peek().map(|line| line.is_quiet()).unwrap_or(false);
loop { loop {
if lines.peek().is_none() { if lines.peek().is_none() {
break; break;
@ -221,7 +222,6 @@ impl<'src, D> Recipe<'src, D> {
} }
} }
let mut command = evaluated.as_str(); let mut command = evaluated.as_str();
let quiet_command = command.starts_with('@');
if quiet_command { if quiet_command {
command = &command[1..]; command = &command[1..];
} }

View File

@ -2516,3 +2516,36 @@ test! {
stderr: "", stderr: "",
shell: false, shell: false,
} }
test! {
name: interpolation_evaluation_ignore_quiet,
justfile: r#"
foo:
{{"@echo foo 2>/dev/null"}}
"#,
args: (),
stdout: "",
stderr: "
@echo foo 2>/dev/null
error: Recipe `foo` failed on line 2 with exit code 127
",
status: 127,
shell: false,
}
test! {
name: interpolation_evaluation_ignore_quiet_continuation,
justfile: r#"
foo:
{{""}}\
@echo foo 2>/dev/null
"#,
args: (),
stdout: "",
stderr: "
@echo foo 2>/dev/null
error: Recipe `foo` failed on line 3 with exit code 127
",
status: 127,
shell: false,
}