1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +00:00

Shell: Print the full name of missing interpreters

We were missing two characters at the end due to a mix-up when skipping
over the first two characters ("#!")
This commit is contained in:
Andreas Kling 2020-05-17 12:32:46 +02:00
parent 7b5b4bee70
commit 656d1e1318

View file

@ -1209,7 +1209,7 @@ ExitCodeOrContinuationRequest Shell::run_command(const StringView& cmd)
if ((shebang_fd >= 0) && ((num_read = read(shebang_fd, shebang, sizeof(shebang))) >= 2) && (StringView(shebang).starts_with("#!"))) {
StringView shebang_path_view(&shebang[2], num_read - 2);
Optional<size_t> newline_pos = shebang_path_view.find_first_of("\n\r");
shebang[newline_pos.has_value() ? newline_pos.value() : num_read] = '\0';
shebang[newline_pos.has_value() ? (newline_pos.value() + 2) : num_read] = '\0';
fprintf(stderr, "%s: Invalid interpreter \"%s\": %s\n", argv[0], &shebang[2], strerror(ENOENT));
} else
fprintf(stderr, "%s: Command not found.\n", argv[0]);