mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 03:16:51 +01:00
「🔨」 fix(switch_cmd_path): path to . if no path
This commit is contained in:
@ -6,12 +6,13 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/09 19:25:18 by adjoly #+# #+# */
|
/* Created: 2024/07/09 19:25:18 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/08/14 10:23:48 by mmoussou ### ########.fr */
|
/* Updated: 2024/08/14 10:51:19 by mmoussou ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
#include "builtins.h"
|
||||||
|
|
||||||
int is_in_builtins(char *cmd)
|
int is_in_builtins(char *cmd)
|
||||||
{
|
{
|
||||||
@ -84,6 +85,12 @@ int switch_cmd_path(t_cmd *cmd, t_env *env)
|
|||||||
else if (cmd->cmd[0] != '/')
|
else if (cmd->cmd[0] != '/')
|
||||||
{
|
{
|
||||||
path = env_get_value("PATH", env);
|
path = env_get_value("PATH", env);
|
||||||
|
if (!path || !path[0])
|
||||||
|
{
|
||||||
|
if (path)
|
||||||
|
free(path);
|
||||||
|
path = ft_strdup(ret_cwd());
|
||||||
|
}
|
||||||
cmd->cmd = get_path(path, cmd->cmd);
|
cmd->cmd = get_path(path, cmd->cmd);
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user