Merge pull request #11338 from NixOS/backport-11332-to-2.20-maintenance

[Backport 2.20-maintenance] [Backport 2.22-maintenance] fix: check to see if there are any lines before
This commit is contained in:
Robert Hensing 2024-08-19 17:11:45 +02:00 committed by GitHub
commit 8b906d3811
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -134,7 +134,7 @@ static void main_nix_build(int argc, char * * argv)
script = argv[1];
try {
auto lines = tokenizeString<Strings>(readFile(script), "\n");
if (std::regex_search(lines.front(), std::regex("^#!"))) {
if (!lines.empty() && std::regex_search(lines.front(), std::regex("^#!"))) {
lines.pop_front();
inShebang = true;
for (int i = 2; i < argc; ++i)