chk_built_in.c
/**
* _cd - change directory to home or given path
* @tokens: pointer to the tokens
* @env: pointer to env variables
* @buffer: buffer
* @av: argv
* Return: 1
*/
change directory to home or given path
change directory to home or given path
int _cd(char ***tokens, char **env, char **buffer, char **av)
{
	char *env_home = NULL;
	char *env_pwd = NULL;
	int chdir_status;
	(void) tokens;
	(void) buffer;
	(void) av;
	env_home = _getenv("HOME", env);
	env_pwd = _getenv("PWD", env);
	if ((*tokens)[1] == NULL || _strcmp((*tokens)[1], "~") == 0 ||
	_strcmp((*tokens)[1], "$HOME") == 0)
	{
		chdir_status = chdir(env_home);
	}
	if (_strcmp((*tokens)[1], "-") == 0)
		chdir_status = chdir(env_pwd);
	chdir_status = chdir((*tokens)[1]);
	return (chdir_status);
}
int _cd ( char * * * tokens , char * * env , char * * buffer , char * * av ) { char * env_home = NULL ; char * env_pwd = NULL ; int chdir_status ; ( void ) tokens ; ( void ) buffer ; ( void ) av ; env_home = _getenv ( " " , env ) ; env_pwd = _getenv ( " " , env ) ; if ( ( * tokens ) [ 1 ] == NULL || _strcmp ( ( * tokens ) [ 1 ] , " " ) == 0 || _strcmp ( ( * tokens ) [ 1 ] , " " ) == 0 ) { chdir_status = chdir ( env_home ) ; } if ( _strcmp ( ( * tokens ) [ 1 ] , " " ) == 0 ) chdir_status = chdir ( env_pwd ) ; chdir_status = chdir ( ( * tokens ) [ 1 ] ) ; return ( chdir_status ) ; }
_cd - change directory to home or given path
_cd - change directory to home or given path