aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/builtin/cd.c9
-rw-r--r--src/eval/cmd.c2
-rw-r--r--src/eval/eval.c2
-rw-r--r--src/eval/redir.c2
-rw-r--r--src/lexer/utils.c6
-rw-r--r--src/path.c4
-rw-r--r--src/utils.c6
7 files changed, 14 insertions, 17 deletions
diff --git a/src/builtin/cd.c b/src/builtin/cd.c
index a350cf4..1ccfdcb 100644
--- a/src/builtin/cd.c
+++ b/src/builtin/cd.c
@@ -6,7 +6,7 @@
/* By: charles <charles@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/01 17:10:20 by charles #+# #+# */
-/* Updated: 2020/10/09 12:44:55 by cacharle ### ########.fr */
+/* Updated: 2020/10/15 09:38:55 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -40,10 +40,11 @@ int builtin_cd(char **argv, t_env env)
{
if ((home = env_search(env, "HOME", NULL)) == NULL)
return (errorf_ret(1, "cd: HOME not set\n"));
- argv[1] = home;
}
- if (chdir(argv[1]) == -1)
- return (errorf_ret(1, "cd: %s: %s\n", argv[1], strerror(errno)));
+ else
+ home = argv[1];
+ if (chdir(home) == -1)
+ return (errorf_ret(1, "cd: %s: %s\n", home, strerror(errno)));
if (env_export(env, "OLDPWD", oldwd) == NULL)
return (EVAL_FATAL);
if (getcwd(cwd, PATH_MAX) == NULL)
diff --git a/src/eval/cmd.c b/src/eval/cmd.c
index 5bc397d..6b419f7 100644
--- a/src/eval/cmd.c
+++ b/src/eval/cmd.c
@@ -6,7 +6,7 @@
/* By: charles <charles@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/14 10:41:31 by charles #+# #+# */
-/* Updated: 2020/10/10 12:57:23 by cacharle ### ########.fr */
+/* Updated: 2020/10/15 09:41:48 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/src/eval/eval.c b/src/eval/eval.c
index c2aaf8c..d7229f7 100644
--- a/src/eval/eval.c
+++ b/src/eval/eval.c
@@ -6,7 +6,7 @@
/* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/09/13 20:38:06 by charles #+# #+# */
-/* Updated: 2020/10/10 13:00:11 by cacharle ### ########.fr */
+/* Updated: 2020/10/15 10:28:51 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/src/eval/redir.c b/src/eval/redir.c
index 8c154d5..257f26a 100644
--- a/src/eval/redir.c
+++ b/src/eval/redir.c
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/15 11:05:34 by charles #+# #+# */
-/* Updated: 2020/10/10 11:40:16 by cacharle ### ########.fr */
+/* Updated: 2020/10/15 10:28:23 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/src/lexer/utils.c b/src/lexer/utils.c
index 0d8080c..b16a69a 100644
--- a/src/lexer/utils.c
+++ b/src/lexer/utils.c
@@ -6,7 +6,7 @@
/* By: nahaddac <nahaddac@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/16 08:18:15 by nahaddac #+# #+# */
-/* Updated: 2020/10/10 08:38:46 by cacharle ### ########.fr */
+/* Updated: 2020/10/15 10:32:00 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,12 +22,12 @@ enum e_tok tok_assign_tag(char *content)
return (TAG_OR);
if (content[0] == '|')
return (TAG_PIPE);
+ if (ft_strncmp(content, ">>", 2) == 0)
+ return (TAG_REDIR_APPEND);
if (content[0] == '>')
return (TAG_REDIR_OUT);
if (content[0] == '<')
return (TAG_REDIR_IN);
- if (ft_strncmp(content, ">>", 2) == 0)
- return (TAG_REDIR_APPEND);
if (content[0] == '(')
return (TAG_PARENT_OPEN);
if (content[0] == ')')
diff --git a/src/path.c b/src/path.c
index 3819555..a49cc6d 100644
--- a/src/path.c
+++ b/src/path.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/27 15:51:01 by cacharle #+# #+# */
-/* Updated: 2020/10/09 13:36:26 by cacharle ### ########.fr */
+/* Updated: 2020/10/15 09:35:31 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -40,7 +40,7 @@ static bool st_dir_search(
return (false);
while ((entry = readdir(dir)) != NULL)
{
- if (ft_strcmp(entry->d_name, exec_name) == 0)
+ if (ft_strcasecmp(entry->d_name, exec_name) == 0)
{
ft_strcpy(exec_path, dirname);
ft_strcat(exec_path, "/");
diff --git a/src/utils.c b/src/utils.c
index 4125eba..6efc0d1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -6,7 +6,7 @@
/* By: cacharle <cacharle@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 11:56:31 by cacharle #+# #+# */
-/* Updated: 2020/10/10 11:12:47 by cacharle ### ########.fr */
+/* Updated: 2020/10/15 09:39:27 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,7 +24,6 @@
void print_prompt(void)
{
char cwd[PATH_MAX + 1];
- char *last_slash;
ft_bzero(cwd, PATH_MAX + 1);
if (getcwd(cwd, PATH_MAX) == NULL)
@@ -32,9 +31,6 @@ void print_prompt(void)
ft_putstr_fd("$ ", STDERR_FILENO);
return ;
}
- last_slash = ft_strrchr(cwd, '/');
- if (last_slash != NULL && ft_strlen(cwd) != 1)
- ft_strcpy(cwd, last_slash + 1);
ft_putstr_fd("\033[0;32m", STDERR_FILENO);
ft_putstr_fd(cwd, STDERR_FILENO);
ft_putstr_fd("\033[0m$ ", STDERR_FILENO);