From ed8aecde86ec799292af8e1e51fb1b85b5eddbb8 Mon Sep 17 00:00:00 2001 From: Dummi26 <markbaumeister26@gmail.com> Date: Thu, 20 Apr 2023 19:37:29 +0200 Subject: [PATCH] added support for shebangs: if the file starts with "#!", the first line will be ignored. --- mers/src/parse/file.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mers/src/parse/file.rs b/mers/src/parse/file.rs index 9c92e23..401f8b2 100755 --- a/mers/src/parse/file.rs +++ b/mers/src/parse/file.rs @@ -32,6 +32,11 @@ impl Display for FilePosition { impl File { pub fn new(data: String, path: PathBuf) -> Self { + let data = if data.starts_with("#!") { + &data[data.lines().next().unwrap().len()..].trim_start() + } else { + data.trim_start() + }; let mut chs = data.chars(); let mut data = String::with_capacity(data.len()); loop {