aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
m---------minishell_test0
-rw-r--r--src/main.c34
3 files changed, 24 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index d0496bf..ccf5433 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
# By: cacharle <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/02/03 04:14:24 by cacharle #+# #+# #
-# Updated: 2020/06/17 16:26:19 by charles ### ########.fr #
+# Updated: 2020/09/13 16:02:22 by charles ### ########.fr #
# #
# **************************************************************************** #
@@ -52,7 +52,7 @@ $(NAME): $(OBJ)
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(INCLUDE)
@echo "Compiling: $@"
- @$(CC) $(CCFLAGS) -c -o $@ $<
+ @$(CC) $(CCFLAGS) $(MINISHELL_TEST_FLAGS) -c -o $@ $<
.PHONY: clean
clean: libft_clean
diff --git a/minishell_test b/minishell_test
-Subproject 13fa2431ce628fbd8e64b18e40bb0eda2ae4605
+Subproject 55fab322485f67112c789a4a529765b5e663523
diff --git a/src/main.c b/src/main.c
index eef076c..caa4462 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,7 +6,7 @@
/* By: cacharle <cacharle@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 11:45:44 by cacharle #+# #+# */
-/* Updated: 2020/09/13 14:23:31 by charles ### ########.fr */
+/* Updated: 2020/09/13 16:11:32 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -53,18 +53,29 @@ int main(int argc, char **argv, char **envp)
char buf[PATH_MAX] = {0};
if (!(getcwd(buf, PATH_MAX)))
return(1);
+
+ char *shlvl_str = env_search(env, "SHLVL");
+ if (shlvl_str != NULL)
+ {
+ shlvl_str = ft_itoa(ft_atoi(shlvl_str));
+ env_export(env, "SHLVL", shlvl_str);
+ free(shlvl_str);
+ }
+
if (!env_set_default(env, "PWD", buf) ||
- !env_set_default(env, "SHLVL", "0") || // TODO increment if set
- !env_set_default(env, "PATH", "/sbin:")) // FIXME need to prefix if /sbin not in
+ !env_set_default(env, "SHLVL", "0") ||
+ !env_set_default(env, "PATH", "/sbin:"))
return (1);
- /* char *path_str = env_search(env, "PATH"); */
- /* if (ft_strstr(path_str, "/sbin") == NULL) */
- /* { */
- /* char *value = ft_strjoin("/sbin:", path_str); */
- /* env_export(env, "PATH", value); */
- /* free(value); */
- /* } */
+#ifndef MINISHELL_TEST
+ char *path_str = env_search(env, "PATH");
+ if (ft_strstr(path_str, "/sbin") == NULL)
+ {
+ char *value = ft_strjoin("/sbin:", path_str);
+ env_export(env, "PATH", value);
+ free(value);
+ }
+#endif
path = path_update(NULL, env_search(env, "PATH"));
@@ -96,7 +107,7 @@ int main(int argc, char **argv, char **envp)
tok_lst_debug(lex_out);
/* ft_lstiter((t_ftlst*)lex_out, token_debug); */
}
- else if (argc == 3 && ft_strcmp(argv[1], "-c") == 0)
+ else if (argc == 3 && ft_strcmp(argv[1], "-c") == 0) // put in MINISHELL_TEST
{
t_tok_lst *lex_out = lexer(argv[2]);
if (lex_out == NULL)
@@ -151,7 +162,6 @@ int main(int argc, char **argv, char **envp)
if (status == EVAL_FATAL)
exit(1);
g_last_status = status;
- /* error_set_status(status); */
print_prompt();
}
if (ret != FTGL_EOF)