/*
* Reads a file and determine if it uses a shell bang, and if so display which program it calls
*/
#include <stdio.h>
int main() {
FILE *file=fopen("test", "r");
char data[3];
char *shell,*shell2;
char *tmp;
if(fread(data, 2, 1, file)<=0)
return 0;
if(data[0]=='#' && data[1]=='!') {
shell=malloc(1);
int i=0;
while(fread(data, 1, 1, file)>0) {
if(data[0]=='\n')
break;
shell[i]=data[0];
shell=realloc(shell, i+2);
i++;
}
shell[i]='\0';
printf("%s\n", shell);
}
fclose(file);
}