protection de segv au lancement du shell (redirection entrante & nom de fichier non valid)
This commit is contained in:
parent
d0c9baeeb8
commit
6775120264
2 changed files with 9 additions and 4 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue