--- /dev/null
+{
+ "configurations": [
+ {
+ "name": "macos-clang-x64",
+ "includePath": [
+ "${workspaceFolder}/**"
+ ],
+ "compilerPath": "/usr/bin/clang",
+ "cStandard": "${default}",
+ "cppStandard": "${default}",
+ "intelliSenseMode": "macos-clang-x64",
+ "compilerArgs": [
+ ""
+ ]
+ }
+ ],
+ "version": 4
+ }
\ No newline at end of file
--- /dev/null
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "C/C++ Runner: Debug Session",
+ "type": "lldb",
+ "request": "launch",
+ "args": [],
+ "cwd": "/Users/chuhlig/Desktop/merged_minishell/",
+ "program": "/Users/chuhlig/Desktop/merged_minishell/minishell"
+ }
+ ]
+ }
\ No newline at end of file
--- /dev/null
+{
+ "C_Cpp_Runner.cCompilerPath": "clang",
+ "C_Cpp_Runner.cppCompilerPath": "clang++",
+ "C_Cpp_Runner.debuggerPath": "lldb",
+ "C_Cpp_Runner.cStandard": "",
+ "C_Cpp_Runner.cppStandard": "",
+ "C_Cpp_Runner.msvcBatchPath": "",
+ "C_Cpp_Runner.useMsvc": false,
+ "C_Cpp_Runner.warnings": [
+ "-Wall",
+ "-Wextra",
+ "-Wpedantic",
+ "-Wshadow",
+ "-Wformat=2",
+ "-Wcast-align",
+ "-Wconversion",
+ "-Wsign-conversion",
+ "-Wnull-dereference"
+ ],
+ "C_Cpp_Runner.msvcWarnings": [
+ "/W4",
+ "/permissive-",
+ "/w14242",
+ "/w14287",
+ "/w14296",
+ "/w14311",
+ "/w14826",
+ "/w44062",
+ "/w44242",
+ "/w14905",
+ "/w14906",
+ "/w14263",
+ "/w44265",
+ "/w14928"
+ ],
+ "C_Cpp_Runner.enableWarnings": true,
+ "C_Cpp_Runner.warningsAsError": false,
+ "C_Cpp_Runner.compilerArgs": [],
+ "C_Cpp_Runner.linkerArgs": [],
+ "C_Cpp_Runner.includePaths": [],
+ "C_Cpp_Runner.includeSearch": [
+ "*",
+ "**/*"
+ ],
+ "C_Cpp_Runner.excludeSearch": [
+ "**/build",
+ "**/build/**",
+ "**/.*",
+ "**/.*/**",
+ "**/.vscode",
+ "**/.vscode/**"
+ ],
+ "C_Cpp_Runner.useAddressSanitizer": false,
+ "C_Cpp_Runner.useUndefinedSanitizer": false,
+ "C_Cpp_Runner.useLeakSanitizer": false,
+ "C_Cpp_Runner.showCompilationTime": false,
+ "C_Cpp_Runner.useLinkTimeOptimization": false,
+ "C_Cpp_Runner.msvcSecureNoWarnings": false,
+ "files.associations": {
+ "minishell.h": "c",
+ "debug_tools.h": "c",
+ "token.h": "c"
+ }
+ }
\ No newline at end of file
--- /dev/null
+{
+ "tasks": [
+ {
+ "type": "cppbuild",
+ "label": "C/C++: clang build active file",
+ "command": "/usr/bin/clang",
+ "args": [
+ "-fcolor-diagnostics",
+ "-fansi-escape-codes",
+ "-g",
+ "${file}",
+ "-o",
+ "${fileDirname}/${fileBasenameNoExtension}"
+ ],
+ "options": {
+ "cwd": "${fileDirname}"
+ },
+ "problemMatcher": [
+ "$gcc"
+ ],
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ },
+ "detail": "Task generated by Debugger."
+ }
+ ],
+ "version": "2.0.0"
+}
\ No newline at end of file
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/08 16:53:39 by dkaiser #+# #+# */
-/* Updated: 2025/01/18 18:43:07 by chuhlig ### ########.fr */
+/* Updated: 2025/01/20 16:48:57 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
void update_oldpwd(t_env **env);
void update_pwd(t_env **env);
int unset(char **av, t_env **env);
-int export(char **av, t_env **env);
+int export(char **av, t_env **env, int f);
int echo(char **av);
int pwd(t_env *env);
int cd(t_env **env, char **args);
int builtin_exit(char **args, t_env **env);
t_env *env_new(char *name);
t_env *check_existing(t_env *env, char *av);
+int check_flag(int f);
#endif
\ No newline at end of file
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/22 17:14:49 by dkaiser #+# #+# */
-/* Updated: 2025/01/18 19:30:43 by chuhlig ### ########.fr */
+/* Updated: 2025/01/20 16:48:39 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
char *get_cmd_path(char *cmd, t_env *env, int *return_code);
int execute_cmd(t_cmd *cmd, t_env **env);
char *format_string(char *str, t_env *env, int is_literal);
-int set_return_code(int return_code, t_env **env);
+void set_return_code(int return_code, t_env **env);
int handle_redirections(t_redirection *redirs);
void *error(int err_code, char *err_text, int exit_code,
int *ret_code);
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/09 17:01:16 by chuhlig #+# #+# */
-/* Updated: 2025/01/18 18:33:33 by chuhlig ### ########.fr */
+/* Updated: 2025/01/20 17:05:19 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
prev = NULL;
while (current)
{
- if (ft_strcmp(current->name, av[i]) == 0)
+ if ((!ft_strcmp(current->name, av[i])) && (!ft_strcmp("?", av[1])))
+ {
+ if (prev)
+ prev->next = current->next;
+ else
+ *env = current->next;
+ free_env_node(current);
+ break ;
+ }
{
if (prev)
prev->next = current->next;
return (1);
}
-int export(char **av, t_env **env)
+int export(char **av, t_env **env, int f)
{
char *equal_sign;
int i;
write(1, "Minishell $ export: not a valid identifier\n", 43);
if (equal_sign)
*equal_sign = '=';
+ f++;
continue ;
}
if (equal_sign)
export_export(av[i], env);
}
}
- return (0);
+ return (check_flag(f));
}
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/18 18:29:24 by chuhlig #+# #+# */
-/* Updated: 2025/01/18 18:34:29 by chuhlig ### ########.fr */
+/* Updated: 2025/01/20 17:08:17 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
{
int exit_status;
- if (av[1])
+ if (av[1] && !av[2])
exit_status = ft_atoi(av[1]);
+ else if (av[2])
+ exit_status = 1;
else
exit_status = 0;
exit_shell(env, exit_status);
write(1, "\n", 1);
return (0);
}
+
+int check_flag(int f)
+{
+ if (f)
+ return (1);
+ return (0);
+}
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/17 14:31:07 by chuhlig #+# #+# */
-/* Updated: 2025/01/14 14:44:34 by chuhlig ### ########.fr */
+/* Updated: 2025/01/20 15:05:49 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
{
while (env != NULL)
{
- if (!ft_strncmp(env->name, name, ft_strlen(name)))
+ if (!ft_strncmp(env->name, name, ft_strlen(env->name)))
return (env->value);
env = env->next;
}
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/17 19:21:35 by chuhlig #+# #+# */
-/* Updated: 2025/01/19 19:15:46 by chuhlig ### ########.fr */
+/* Updated: 2025/01/20 15:43:41 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
int execute_builtin(char **args, t_env **env)
{
if (ft_strcmp(args[0], "export") == 0)
- return (export(args, env));
+ return (export(args, env, ft_atoi("0")));
else if (ft_strcmp(args[0], "unset") == 0)
return (unset(args, env));
else if (ft_strcmp(args[0], "cd") == 0)
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/18 18:34:51 by chuhlig #+# #+# */
-/* Updated: 2025/01/18 18:47:31 by chuhlig ### ########.fr */
+/* Updated: 2025/01/20 14:59:38 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
}
else if (redir->type == INPUT_LIMITER)
{
- fd = open_file("/tmp/heredoc_tmp", O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ fd = open_file("/tmp/heredoc_tmp", O_WRONLY | O_TRUNC, 0644);
if (fd < 0)
return (-1);
write(fd, redir->specifier, ft_strlen(redir->specifier));
if (redir->type == OUTPUT_OVERRIDE)
{
- fd = open_file(redir->specifier, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ fd = open_file(redir->specifier, O_WRONLY | O_TRUNC, 0644);
if (fd < 0)
return (-1);
dup2(fd, STDOUT_FILENO);
}
else if (redir->type == OUTPUT_APPEND)
{
- fd = open_file(redir->specifier, O_WRONLY | O_CREAT | O_APPEND, 0644);
+ fd = open_file(redir->specifier, O_WRONLY | O_APPEND, 0644);
if (fd < 0)
return (-1);
dup2(fd, STDOUT_FILENO);