removed path from non existant commands
This commit is contained in:
@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strchr.c :+: :+: :+: */
|
/* ft_strchr.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/10/30 13:35:44 by tomoron #+# #+# */
|
/* Created: 2023/10/30 13:35:44 by tomoron #+# #+# */
|
||||||
/* Updated: 2023/11/02 11:08:17 by tomoron ### ########.fr */
|
/* Updated: 2024/03/21 16:41:59 by marde-vr ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
@ -17,6 +17,8 @@ char *ft_strchr(const char *s, int c)
|
|||||||
char *res;
|
char *res;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
if (!s)
|
||||||
|
return (NULL);
|
||||||
res = (char *)s;
|
res = (char *)s;
|
||||||
while (res[i])
|
while (res[i])
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/05 18:22:15 by marde-vr #+# #+# */
|
/* Created: 2024/03/05 18:22:15 by marde-vr #+# #+# */
|
||||||
/* Updated: 2024/03/05 18:24:19 by marde-vr ### ########.fr */
|
/* Updated: 2024/03/21 13:51:22 by marde-vr ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ char **get_cmd_args(t_msh *msh)
|
|||||||
{
|
{
|
||||||
if (cur_cmd->type == ARG)
|
if (cur_cmd->type == ARG)
|
||||||
{
|
{
|
||||||
cmd_args[i] = cur_cmd->token;
|
cmd_args[i] = remove_path(cur_cmd->token);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/03/06 08:32:18 by marde-vr ### ########.fr */
|
/* Updated: 2024/03/21 13:55:20 by marde-vr ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -88,7 +88,6 @@ int main(int argc, char **argv, char **envp)
|
|||||||
|
|
||||||
commands = (char *)1;
|
commands = (char *)1;
|
||||||
init_minishell(&msh, argc, argv, envp);
|
init_minishell(&msh, argc, argv, envp);
|
||||||
//handle_minishellrc(msh);
|
|
||||||
while (msh->env && commands)
|
while (msh->env && commands)
|
||||||
{
|
{
|
||||||
prompt = get_prompt(msh->env);
|
prompt = get_prompt(msh->env);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/03/06 10:19:27 by marde-vr ### ########.fr */
|
/* Updated: 2024/03/21 13:30:59 by marde-vr ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -117,5 +117,6 @@ int get_args_count(t_cmd *cmds);
|
|||||||
char **get_cmd_args(t_msh *msh);
|
char **get_cmd_args(t_msh *msh);
|
||||||
void remove_command_from_msh(t_msh *msh);
|
void remove_command_from_msh(t_msh *msh);
|
||||||
int file_access(t_msh *msh, int *found);
|
int file_access(t_msh *msh, int *found);
|
||||||
|
char *remove_path(char *token);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
srcs/path.c
12
srcs/path.c
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/21 21:47:15 by marde-vr #+# #+# */
|
/* Created: 2024/02/21 21:47:15 by marde-vr #+# #+# */
|
||||||
/* Updated: 2024/03/06 10:18:53 by marde-vr ### ########.fr */
|
/* Updated: 2024/03/21 16:39:06 by marde-vr ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -93,6 +93,16 @@ void get_path(t_msh *msh, int *found)
|
|||||||
free_paths(paths);
|
free_paths(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *remove_path(char *token)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (ft_strchr(token, '/'))
|
||||||
|
token++;
|
||||||
|
return (token);
|
||||||
|
}
|
||||||
|
|
||||||
void get_cmd_path(t_msh *msh)
|
void get_cmd_path(t_msh *msh)
|
||||||
{
|
{
|
||||||
int found;
|
int found;
|
||||||
|
Reference in New Issue
Block a user