Change handling of invalid command
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 5 Sep 2024 07:42:20 +0000 (09:42 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 5 Sep 2024 07:45:23 +0000 (09:45 +0200)
Before it made execution fail which made || not function properly.
Now invalid command makes the execution chain not fail.
An error message was also added.

src/execute_raw.c

index 6b01f1e5f8d43390045b9b700da4f03015fc9d2e..8be11b86b106699db0e328520c3d11b9bb054d40 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: lnikolov <lnikolov@student.42prague.com    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/09/01 11:53:16 by lnikolov          #+#    #+#             */
-/*   Updated: 2024/09/01 13:29:27 by lnikolov         ###   ########.fr       */
+/*   Updated: 2024/09/05 09:41:33 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -58,7 +58,10 @@ static char  *get_path(const char *cmd, t_execution_env *env)
        else if (!contains_path(cmd))
                path = find_exe(cmd, env);
        if (!path)
+       {
+               ft_dprintf(STDERR_FILENO, "minishell: command not found: %s\n", cmd);
                env->ret_val = 127;
+       }
        return (path);
 }
 
@@ -73,7 +76,7 @@ int   ex_fields(char **fields, t_vec *assignments,
                return (ex_builtin(fields, assignments, redirections, env));
        path = get_path(fields[0], env);
        if (!path)
-               return (1);
+               return (0);
        pid = fork();
        if (pid == 0)
        {