fix: cd erro

This commit is contained in:
Laureηt 2021-04-20 19:03:25 +02:00
parent 30406e3ef9
commit bf697c4939
2 changed files with 4 additions and 3 deletions

BIN
minishell

Binary file not shown.

View file

@ -68,15 +68,16 @@ int main(int argc, char *argv[])
}
else if (!strcmp(cmd->seq[0][0], "cd"))
{ // cd
int ret = 0;
if (cmd->seq[0][1] == NULL)
{ // vide
chdir(initcd);
ret = chdir(initcd);
}
else
{ // avec un path
chdir(cmd->seq[0][1]);
ret = chdir(cmd->seq[0][1]);
}
if (errno)
if (ret)
{ // si le path n'existe pas
fprintf(stderr, "ERROR: cd failed, (%d) %s\n", errno, strerror(errno));
}