From 12ef94df5ecdf03fd7f08d43eaa46d56209e6d95 Mon Sep 17 00:00:00 2001 From: Rerumu <25379555+Rerumu@users.noreply.github.com> Date: Thu, 9 Dec 2021 15:37:48 -0500 Subject: [PATCH] Add shebang support (#149) Co-authored-by: Arseny Kapoulkine --- CLI/FileUtils.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CLI/FileUtils.cpp b/CLI/FileUtils.cpp index b3c9557b..cb993dfe 100644 --- a/CLI/FileUtils.cpp +++ b/CLI/FileUtils.cpp @@ -67,6 +67,10 @@ std::optional readFile(const std::string& name) if (read != size_t(length)) return std::nullopt; + // Skip first line if it's a shebang + if (length > 2 && result[0] == '#' && result[1] == '!') + result.erase(0, result.find('\n')); + return result; }