I'm trying to make my own cd command. When I try to run :
It works for any existing subdirectory and ".."(as in move up one level).
int main(int argc, char *argv)
if( strcpy(path, argv) < 0)
printf("error converting argv to string\n");
printf("argv converted to string\n");
if (argc != 2)
if (chdir(path) < 0)
if (getcwd(cwd, sizeof(cwd)) != NULL)
fprintf(stdout, "You are in %s\n", cwd);
However if I try to cd to any directory that does not exist or any directory that is above the current directory, I get the error Abort Trap. I have no idea what that means, this error is not listed in the man pages for either strcpy() or chdir() which is where i would assume the error to be happening.
Any help will be appreciated.