mdirs: reset cwd after each iteration

Else `mdirs dir1/a dir2/b` fails, as the first iteration remains in `dir1`.
Found by milliardo.
pull/147/head
Leah Neukirchen 6 years ago
parent 7ea96a6dea
commit 41098c3851

@ -83,8 +83,19 @@ usage:
if (argc == optind)
goto usage;
for (i = 0; i < argc; i++)
char toplevel[PATH_MAX];
if (!getcwd(toplevel, sizeof toplevel)) {
perror("mdirs: getcwd");
exit(-1);
}
for (i = 0; i < argc; i++) {
mdirs(argv[i]);
if (chdir(toplevel) < 0) {
perror("mdirs: chdir");
exit(-1);
}
}
return 0;
}

Loading…
Cancel
Save