#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

/*
	These are the directory and file functions built into SpenceShell
	10/08/2000 - added change dir
*/

int cd(char thedir[256])
{
	//char *svptr;
	//char *s;
	char *home;
	//static const char delim[] = " \t\n";
	//s = strtok_r(thedir,delim,&svptr);
	//s = strtok_r(NULL,delim,&svptr);
	if(strstr(thedir,"~")) {
		home = getenv("HOME");
		//printf("%s",home);
		if (chdir(home) != 0)
			perror("Error");	
	} else if ( chdir(thedir) != 0)
		perror("Error");
	return 0;
}
