Created
April 6, 2020 20:37
-
-
Save davixcky/2c2afeb7b042cacc57414d775645a61d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char *_strcat(char *dest, char *src) | |
{ | |
int l_dest, i; | |
l_dest = _strlen(dest); | |
for (i = 0; src[i] != '\0'; i++, l_dest++) | |
dest[l_dest] = src[i]; | |
dest[l_dest] = '\0'; | |
return (dest); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "shell.h" | |
/** | |
* _which - Find the directory needed | |
* @command: Command received | |
* | |
* Return: pointer string with found path or NULL in failure. | |
*/ | |
char *_which(char *command) | |
{ | |
char **path; | |
char *split; | |
char *aux; | |
char *tmp; | |
int x = 0; | |
if (!command) | |
return (NULL); | |
tmp = _strdup(command); | |
command = _strdup("/"); | |
_strcat(command, tmp); | |
split = _getenv("PATH"); | |
path = split_line(split); | |
while (path[x] != NULL) | |
{ | |
split = _strcat(path[x], command); | |
if (_stat(split) == 0) | |
return (split); | |
x++; | |
} | |
return (NULL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment