diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-10-06 17:40:58 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-10-06 17:40:58 +0200 |
| commit | 22ff0337dc23239c32cc738bb6f576b8a0b66f8b (patch) | |
| tree | 215d56c87db9a21394b41251ee5790a88ebb0754 | |
| parent | 89bd998bcf0839a83daf16ab9b1e8ae568a8a9f2 (diff) | |
| download | minishell-22ff0337dc23239c32cc738bb6f576b8a0b66f8b.tar.gz minishell-22ff0337dc23239c32cc738bb6f576b8a0b66f8b.tar.bz2 minishell-22ff0337dc23239c32cc738bb6f576b8a0b66f8b.zip | |
Fixing macos error messages and SHLVL
| -rw-r--r-- | src/builtin/export.c | 18 | ||||
| -rw-r--r-- | src/eval/operation.c | 2 | ||||
| -rw-r--r-- | src/parser/parser.c | 4 | ||||
| -rw-r--r-- | src/path.c | 4 | ||||
| -rw-r--r-- | src/setup.c | 4 |
5 files changed, 12 insertions, 20 deletions
diff --git a/src/builtin/export.c b/src/builtin/export.c index e6fca73..96ec18c 100644 --- a/src/builtin/export.c +++ b/src/builtin/export.c @@ -6,7 +6,7 @@ /* By: charles <charles@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:11:34 by charles #+# #+# */ -/* Updated: 2020/09/15 17:49:35 by charles ### ########.fr */ +/* Updated: 2020/10/06 17:40:22 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,19 +39,11 @@ static void st_put_declare_x(char *s) ft_putstr(s); ft_putchar('='); ft_putchar('"'); - if (ft_strcmp(s, "SHLVL") == 0) + while (*++equal_ptr != '\0') { - shlvl = ft_atoi(equal_ptr + 1); - ft_putnbr(shlvl + 1); - } - else - { - while (*++equal_ptr != '\0') - { - if (*equal_ptr == '"') - ft_putchar('\\'); - ft_putchar(*equal_ptr); - } + if (*equal_ptr == '"') + ft_putchar('\\'); + ft_putchar(*equal_ptr); } ft_putchar('"'); ft_putchar('\n'); diff --git a/src/eval/operation.c b/src/eval/operation.c index df54346..8442533 100644 --- a/src/eval/operation.c +++ b/src/eval/operation.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/17 15:27:22 by charles #+# #+# */ -/* Updated: 2020/10/06 17:21:38 by cacharle ### ########.fr */ +/* Updated: 2020/10/06 17:31:43 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/parser/parser.c b/src/parser/parser.c index 80f7349..99c9c8b 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -6,7 +6,7 @@ /* By: nahaddac <nahaddac@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/17 18:09:04 by nahaddac #+# #+# */ -/* Updated: 2020/10/06 16:26:48 by cacharle ### ########.fr */ +/* Updated: 2020/10/06 17:28:31 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,7 +45,7 @@ t_parsed *parse_redir(t_tok_lst *input, t_tok_lst **redirs) && input->next != NULL && input->next->tag & TAG_IS_STR) tok_lst_push_back(redirs, tok_lst_uncons(&input)); if (input == NULL) - return (NULL); + return (parsed_error("syntax error near unexpected token `newline'\n")); if (!(input->tag & TAG_IS_STR)) return (parsed_error("syntax error near unexpected token `%s'\n", input->content)); tok_lst_push_back(redirs, tok_lst_uncons(&input)); @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/27 15:51:01 by cacharle #+# #+# */ -/* Updated: 2020/09/16 19:28:34 by charles ### ########.fr */ +/* Updated: 2020/10/06 17:26:05 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,7 @@ static int st_path_check(char exec_path[PATH_MAX + 1], bool in_path) if (stat(exec_path, &statbuf) == -1) return (errorf_ret(127, "%s: %s\n", exec_path, strerror(errno))); if (S_ISDIR(statbuf.st_mode)) - return (errorf_ret(126, "%s: Is a directory\n", exec_path)); + return (errorf_ret(126, "%s: is a directory\n", exec_path)); if (!in_path && !(statbuf.st_mode & 0444)) return (errorf_ret(126, "%s: %s\n", exec_path, strerror(EACCES))); return (0); diff --git a/src/setup.c b/src/setup.c index 61d5ba5..34b9d2c 100644 --- a/src/setup.c +++ b/src/setup.c @@ -6,7 +6,7 @@ /* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/09/16 15:46:09 by charles #+# #+# */ -/* Updated: 2020/09/16 16:24:28 by charles ### ########.fr */ +/* Updated: 2020/10/06 17:36:40 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,7 +26,7 @@ bool setup_env(t_env env) if (!(getcwd(buf, PATH_MAX))) return (false); if (!st_export_default(env, "PWD", buf) || - !st_export_default(env, "SHLVL", "0") || + !st_export_default(env, "SHLVL", "1") || !st_export_default(env, "PATH", "/sbin:")) return (false); |
