Fix tab-indented lines in shebang recipes
Fixed a precedence bug in the recipe parser where tab-indented lines in a shebang recipe would trigger an ExtraLeadingWhitespace error.
This commit is contained in:
parent
ac996f8940
commit
9f2568c461
@ -988,7 +988,7 @@ impl<'a> Display for RunError<'a> {
|
||||
match *self {
|
||||
RunError::UnknownRecipes{ref recipes} => {
|
||||
if recipes.len() == 1 {
|
||||
try!(write!(f, "Justfile does not contain recipe: {}", recipes[0]));
|
||||
try!(write!(f, "Justfile does not contain recipe `{}`", recipes[0]));
|
||||
} else {
|
||||
try!(write!(f, "Justfile does not contain recipes: {}", recipes.join(" ")));
|
||||
};
|
||||
@ -1528,7 +1528,8 @@ impl<'a> Parser<'a> {
|
||||
if token.lexeme.starts_with("#!") {
|
||||
shebang = true;
|
||||
}
|
||||
} else if !shebang && token.lexeme.starts_with(' ') || token.lexeme.starts_with('\t') {
|
||||
} else if !shebang && (token.lexeme.starts_with(' ') ||
|
||||
token.lexeme.starts_with('\t')) {
|
||||
return Err(token.error(ErrorKind::ExtraLeadingWhitespace));
|
||||
}
|
||||
}
|
||||
|
19
src/unit.rs
19
src/unit.rs
@ -302,6 +302,25 @@ y:
|
||||
z:");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_shebang() {
|
||||
parse_summary("
|
||||
practicum = 'hello'
|
||||
install:
|
||||
\t#!/bin/sh
|
||||
\tif [[ -f {{practicum}} ]]; then
|
||||
\t\treturn
|
||||
\tfi
|
||||
", "practicum = \"hello\"
|
||||
|
||||
install:
|
||||
#!/bin/sh
|
||||
if [[ -f {{practicum}} ]]; then
|
||||
\treturn
|
||||
fi"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_assignments() {
|
||||
parse_summary(
|
||||
|
Loading…
Reference in New Issue
Block a user