There was no limit on the history specified. It appears that what I am supposed to do is replicate the history features of csh.
I found another piece of code from a student who I believe may be doing something similar:
Code:
while(fgets(input, sizeof(input), stdin) != NULL){
filePrint = fopen(".simpleshell_history", "a");
fileRead = fopen(".simpleshell_history", "r");
count++;
fprintf(filePrint, "%d - %s", count, input);
fclose(filePrint);
if (strcmp(input,"history")==0){
printf("%sn", input);
fseek(fileRead, 0, SEEK_SET);
int x = 0;
while ((x = fgetc(fileRead)) != EOF){
printf("%c", x);
}
}
}
However, I tried running it just to see if it was even a reasonable start for the task, and the history started over at 1 every time the shell program was launched. So, it did not work. I am hoping to implement this in the simplest way possible but nothing I have tried thus far has worked.