Add shebang support (#149)

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
This commit is contained in:
Rerumu 2021-12-09 15:37:48 -05:00 committed by GitHub
parent 2e6a2090c3
commit 12ef94df5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,6 +67,10 @@ std::optional<std::string> 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;
}