From c970f507adeabf58fd3564202d41d750ffea6849 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sun, 2 Oct 2016 15:46:25 -0700 Subject: [PATCH] Split command correctly on leading whitespace --- src/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index bd92ff5..f813f79 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,7 +130,7 @@ struct Justfile<'a> { fn parse<'a>(text: &'a str) -> Result { let shebang_re = re(r"^\s*#!(.*)$"); let comment_re = re(r"^\s*#[^!].*$"); - let command_re = re(r"^(\s+)(.*)$"); + let command_re = re(r"^(\s+).*$"); let blank_re = re(r"^\s*$"); let label_re = re(r"^([a-z](-[a-z]|[a-z])*):(.*)$"); let name_re = re(r"^[a-z](-[a-z]|[a-z])*$"); @@ -157,8 +157,7 @@ fn parse<'a>(text: &'a str) -> Result { found: leading_whitespace, })); } - let command = captures.at(2).unwrap(); - recipe.commands.push(command); + recipe.commands.push(line.split_at(recipe.leading_whitespace.len()).1); current_recipe = Some(recipe); continue; },