Own Shell: Displaying prompt and write a command
Hi,
I'm building my own shell, I've search on the forums but I couldn't find this anywhere.
I have something like this:
Code:
void showPrompt(){
char buff[200];
getcwd(buff, sizeof(buff));
printf("%s:> ", buff);
}
.
.
.
And on the main function:
Code:
.
.
.
do{
showPrompt();
if(strcmp(argv[0], "Pwd") == 0){
printf("%s\n", Pwd() );
}
if(strcmp(argv[0], "Exit") == 0){
exit(1);
}
}while(Exit != 1);
what happens when I run the program is that every char, word, number and even any command I write, it gives me the current location.
I assume that my showPrompt function is very badly done and the program is showing me the getcwd/pwd all the time?
Could anyone help me out making a good showPrompt function?
Thanks in advance!