cd also updates the PWD env var, but the supplied dir can also be relative (. or ..) and should then be resolved in the PWD var. Here's the code:
case CD: ; // (hackhackhack to allow declarions inside a switch)
char *dir;
if (comd->length == 1)
dir = getenv("HOME");
else {
CHK_ARGC("cd",1);
dir = comd->cmd[1];
}
CHK_ERR(chdir(dir), "cd");
setenv("PWD", dir, 1); // BUG: dir can be relative and should then be resolved
return EXIT_SUCCESS;
break;
cd
also updates the PWD env var, but the supplied dir can also be relative (. or ..) and should then be resolved in the PWD var. Here's the code: