i am doing a project about shell, and i want the code that gives me the path the system() function uses.
example, when i enter the command
type dir
the reply will be
dir is external command (/bin/dir)
this is what i reached, but its not working
else if(strcmp(arg3[0],"type")==0) //if type command
{
if(strcmp(arg3[1],"cat")==0 || strcmp(arg3[1],"rm")==0 || strcmp(arg3[1],"rmdir")==0 || strcmp(arg3[1],"ls")==0 || strcmp(arg3[1],"cp")==0 || strcmp(arg3[1],"mv")==0 || strcmp(arg3[1],"exit")==0 || strcmp(arg3[1],"sleep")==0 || strcmp(arg3[1],"type")==0|| strcmp(arg3[1],"history") ==0)
{
printf("%s is a Rshell builtin\n", arg3[1]);
}
else
{
printf("%s is an external command\n", arg3[1]);
char * pPath;
pPath = getenv ("PATH");
if (pPath!=NULL)
printf ("The current path is: %s",pPath);
}
}