Commit c9a0ae73 authored by pêle-mêle's avatar pêle-mêle
Browse files

update notes.txt

parent ae09acea
......@@ -4,10 +4,14 @@ same for CTRL-\, after "^\Quit"
CTRL-D apres avoir ecrit un debut de cmd
echo > $unknown_var ; ls (redir ambigue mais il fait quand meme ls)
$unknown_var ; ls ; ls (premiere commande vide mais il fait quand meme ls)
echo > $unknown_var ; ls ; ls (redir ambigue mais il fait quand meme ls)
create file when redirecting output without doing anything ("> a")
error when redir_in file does not exist ("< unknown_file")
commande "."
compare with bash: "cat | exit"
......@@ -15,6 +19,11 @@ compare with bash: "cat | exit"
"cat |"
then "ls"
check_syntax:
echo "'"
echo '\'
echo '"'
......@@ -29,6 +38,7 @@ builtins: set stat_loc?
mkdir ok; cd ok; rmdir ../ok; pwd
cd: leaks in getcwd
......
#include <unistd.h>
#include <stdlib.h>
static int line_init(char **line, int offset, int ret)
{
if (!(*line = malloc((offset + 1) * sizeof(char))))
return (-1);
((*line)[offset]) = '\0';
return (ret);
}
static int recursive_get_line(char **line, int fd, int offset)
{
char buffer;
int ret;
ret = read(fd, &buffer, 1);
if (ret == 1)
{
if (buffer == '\n' || buffer == '\0')
return (line_init(line, offset, 1));
else
{
ret = recursive_get_line(line, fd, offset + 1);
if ((*line) != NULL)
((*line)[offset]) = buffer;
return (ret);
}
}
else if (ret == 0)
return (line_init(line, offset, 0));
return (-1);
}
int rec_gnl(int fd, char **line)
{
char buffer;
if (fd < 0 || !line || read(fd, &buffer, 0) < 0)
return (-1);
*line = NULL;
return (recursive_get_line(line, fd, 0));
}
......@@ -83,6 +83,7 @@ int clean_and_exit(int ret, t_xe *xe)
free_str_array(xe->env); // besoin de free?
free(xe);
if (ret != CHILD_EXIT)
if (isatty(STDIN_FILENO)) // temp pour le testeur
write(1, "exit\n", 5);
exit(EXIT_SUCCESS);
}
......
......@@ -33,9 +33,17 @@ char *double_quote(t_state_machine *machine, char *line)
char *quoted_backslash(t_state_machine *machine, char *line)
{
if (!ft_isset(*line, "\\\"$"))
if (ft_isset(*line, "\\\"$"))
{
if (add_to_buf(machine, *line) == FAILURE)
return (NULL);
line++;
}
else
{
if (add_to_buf(machine, '\\') == FAILURE)
return (NULL);
}
machine->state = DOUBLE_QUOTE;
return (line);
}
......
#!/bin/bash
./minishell < tester_input > output___minishell
bash --posix < tester_input > output___bash
bash < tester_input > output___bash
diff -s output___minishell output___bash
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment