aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-10-15 09:42:53 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-10-15 09:42:53 +0200
commit753630fe796eb53976696972ee7e20aebd8b1365 (patch)
tree7a3d5915cf5d73abdec840a09e1c5627d5de0feb
parent1352a826b11148a23633504c9d3c246aeaacb1f7 (diff)
downloadminishell-753630fe796eb53976696972ee7e20aebd8b1365.tar.gz
minishell-753630fe796eb53976696972ee7e20aebd8b1365.tar.bz2
minishell-753630fe796eb53976696972ee7e20aebd8b1365.zip
Fixing case insensitive executable path, Removing prompt basename
-rw-r--r--.gitmodules4
m---------minishell_test0
-rw-r--r--src/builtin/cd.c4
-rw-r--r--src/eval/cmd.c2
-rw-r--r--src/path.c4
-rw-r--r--src/utils.c6
6 files changed, 9 insertions, 11 deletions
diff --git a/.gitmodules b/.gitmodules
index 690d5bf..1834c00 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,9 +1,9 @@
[submodule "libft"]
path = libft
- url = https://github.com/HappyTramp/libft
+ url = https://github.com/cacharle/libft
branch = minishell
[submodule "minishell_test"]
path = minishell_test
- url = https://github.com/HappyTramp/minishell_test
+ url = https://github.com/cacharle/minishell_test
branch = master
diff --git a/minishell_test b/minishell_test
-Subproject a36a27b8ca85adf57b2a9926a53e74e3a3863d3
+Subproject acf8e5d268bc0a0da7a49e878400097a6d824c4
diff --git a/src/builtin/cd.c b/src/builtin/cd.c
index b566272..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/11 21:11:40 by charles ### ########.fr */
+/* Updated: 2020/10/15 09:38:55 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -37,8 +37,10 @@ int builtin_cd(char **argv, t_env env)
if (argv[1] != NULL && argv[1][0] == '\0')
return (env_export(env, "OLDPWD", oldwd) == NULL ? EVAL_FATAL : 0);
if (argv[1] == NULL)
+ {
if ((home = env_search(env, "HOME", NULL)) == NULL)
return (errorf_ret(1, "cd: HOME not set\n"));
+ }
else
home = argv[1];
if (chdir(home) == -1)
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/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);