Skip to content

Commit

Permalink
more work on elfexec
Browse files Browse the repository at this point in the history
Better error messages and set ERRORLEVEL on return.
  • Loading branch information
stsp committed Oct 26, 2024
1 parent 9b3762f commit 6cca478
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2684,14 +2684,27 @@ static void perform_echo(const char *arg)

static void perform_elfexec(const char *arg)
{
#ifdef DJ64
int rc;
#endif
if (!arg || !arg[0])
{
cprintf("Syntax error\r\n");
reset_batfile_call_stack();
return;
}
#ifdef DJ64
elfexec(arg, 0, NULL);
rc = elfexec(arg, 0, NULL);
if (rc == -1)
printf("elfexec failed\n");
else if (rc & (1 << 15))
printf("elfexec: unsupported ELF format or not an ELF file\n");
else
{
char el[16];
snprintf(el, sizeof(el), "%d", rc);
setenv("ERRORLEVEL", el, 1);
}
#else
printf("elfexec unsupported\n");
#endif
Expand Down

0 comments on commit 6cca478

Please sign in to comment.