# include "basic.h"

int cd (int argc, char **argv) {

  int status;
  char *cwd;

  if (argc != 2) {
    fprintf (stderr, "USAGE: cd <path>\n");
    return (FALSE);
  }

  status = chdir (argv[1]);
  if (!status) {
    if ((cwd = getcwd (NULL, 64)) == NULL) {
      fprintf (stderr, "error getting cwd\n");
      return (FALSE);
    }
    fprintf(stderr, "cwd: %s\n", cwd);
    free (cwd);
    return (TRUE);
  }

  fprintf (stderr, "error changing to %s\n", argv[1]);
  return (FALSE);

}

int pwd (int argc, char **argv) {

  char *cwd;

  if (argc != 1) {
    fprintf (stderr, "USAGE: pwd\n");
    return (FALSE);
  }
  
  if ((cwd = getcwd(NULL, 64)) == NULL) {
    fprintf (stderr, "error getting cwd\n");
    return (FALSE);
  }
  fprintf(stderr, "cwd: %s\n", cwd);
  free (cwd);
  return (TRUE);
  
}
