I am building a shell that has to handle cd and ls as a built in.
The basic design is this
forever
issue prompt
parse
react to results of parse
repeat
My plan is to have parse set flags when certain situations occur. For instance when the user enters
cd i want to set a flag and respond to it once parse returns to main.
My problem right now is catching the situation when the user types cd.
//Parse function
void parse(char *t,char **ptrArray)
{
int isBackground = 0;
int j=0;
int i, ch;
ptrArray[0] = t ;
int c;
for(;;)/>{
c = getword(t); //returns the integer length of the word typed. Getword also stores the characters in an array
if(c ==-1){
printf("p2 has terminated due to EOF");
exit(0);
}
if(c ==0){
j++;
ptrArray[j]= NULL;
return;
}
if(ptrArray[0] == "cd"){ //Here is where my question lies
setFlag =1;
}
t = t + c +1;
j++;
ptrArray[j] = t;
}}
It doesnt appear that my program is actually reacting to this when i run it. Am i misunderstanding something with arrays of pointers here?
Any help would be greatly appreciated
Thanks,
Mike

New Topic/Question
Reply



MultiQuote




|