Advertisement
CSenshi

shell - cd

Mar 20th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | None | 0 0
  1. /* Prints working directory */
  2. int cmd_pwd(unused struct tokens *tokens)
  3. {
  4.   char cwd[PATH_MAX];
  5.   char *res = getcwd(cwd, sizeof(cwd));
  6.   if (!res)
  7.   {
  8.     perror(err_msg);
  9.     return -1;
  10.   }
  11.   printf("%s\n", cwd);
  12.   return 0;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement