diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index a4ca3108..8ac2065d 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/02 21:40:50 by ariard ### ########.fr */ +/* Updated: 2017/03/03 17:49:18 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,6 +33,7 @@ int handle_instruction(int fd) if ((ret = readline(fd, get_lexer_stack(lexer) || parser.state == UNDEFINED, &str))) { + ft_putnbr(ret); ft_putstr("bonjour"); if (ret == -1) return (-1); @@ -108,7 +109,11 @@ int main(int ac, char **av) shell_init(ac, av); DG("{inv}{bol}{gre}start of shell{eoc} JOBC is %s", SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF"); - fd = get_input_fd(); + if ((fd = get_input_fd() < 0)) + { + ft_printf("{red}%s: No such file or directory\n{eoc}", SHELL_NAME); + return (1); + } while (handle_instruction(fd) == 0) { // lexer_clean; diff --git a/42sh/src/main/shell_get_avdata.c b/42sh/src/main/shell_get_avdata.c index 6194cbf3..16a34d13 100644 --- a/42sh/src/main/shell_get_avdata.c +++ b/42sh/src/main/shell_get_avdata.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/11 17:14:52 by jhalford #+# #+# */ -/* Updated: 2017/01/19 20:56:05 by ariard ### ########.fr */ +/* Updated: 2017/03/03 17:33:33 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ char *shell_get_avdata() data = data_singleton(); av = data->argv; i = 1; - while (av[i][0] == '-') + while (av[i] && av[i][0] == '-') { if (ft_strcmp(av[i], "--") == 0) {