Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <err.h>
- #include <stdlib.h>
- #include <unistd.h>
- int main(int argc, char *argv[])
- {
- char *shell;
- if (argc != 2)
- errx(1, "Usage: cd /some/path");
- if (chdir(argv[1]) == -1)
- err(1, "chdir");
- shell = getenv("SHELL");
- if (!shell || !*shell)
- shell = "/bin/sh";
- execl(shell, shell, NULL);
- err(1, "exec");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement