Skip to content

Commit

Permalink
Now treating a line starting with #! at the start of a picoc file as a
Browse files Browse the repository at this point in the history
comment line so we can execute it as a shell script.
  • Loading branch information
zik.saleeba committed May 31, 2012
1 parent 654151c commit d9a3edc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions platform/platform_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ char *PlatformReadFile(const char *FileName)
char *ReadText;
FILE *InFile;
int BytesRead;
char *p;

if (stat(FileName, &FileInfo))
ProgramFail(NULL, "can't read file %s\n", FileName);
Expand All @@ -102,6 +103,14 @@ char *PlatformReadFile(const char *FileName)
ReadText[BytesRead] = '\0';
fclose(InFile);

if ((ReadText[0] == '#') && (ReadText[1] == '!'))
{
for (*p = ReadText; (*p != '\r') && (*p != '\n'); ++p)
{
*p = ' ';
}
}

return ReadText;
}

Expand Down

0 comments on commit d9a3edc

Please sign in to comment.