Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benoit
minishell
Commits
c4f2c88f
Commit
c4f2c88f
authored
Jan 22, 2021
by
abenoit
Browse files
ambiguous redirs error setup
parent
aa54197d
Changes
6
Hide whitespace changes
Inline
Side-by-side
inc/execution.h
View file @
c4f2c88f
...
...
@@ -12,7 +12,7 @@
enum
e_exec_errcode
{
HOME_NOT_SET
=
8
,
HOME_NOT_SET
=
9
,
NO_SUCH_FILE
};
...
...
inc/minishell.h
View file @
c4f2c88f
...
...
@@ -62,7 +62,8 @@ enum e_redir_op
NO_REDIR
,
FILEIN
,
FILEOUT
,
APPEND
APPEND
,
AMBIG
};
typedef
struct
s_command
...
...
inc/parsing.h
View file @
c4f2c88f
...
...
@@ -31,7 +31,7 @@ enum e_state
enum
e_parsing_error
{
SQUOTE_MISSING
=
1
0
,
SQUOTE_MISSING
=
1
1
,
DQUOTE_MISSING
,
ESCAPE_NL
,
REDIR_PATH_INVALID
,
...
...
src/exec_handler.c
View file @
c4f2c88f
...
...
@@ -103,6 +103,11 @@ int handle_execution(t_xe *xe, int fd_in, int proc)
cur_command
=
parse_one_command
(
xe
);
if
(
cur_command
==
NULL
)
return
(
MALLOC_ERR
);
if
(
cur_command
->
redir_types
!=
NULL
&&
cur_command
->
redir_types
[
0
]
==
AMBIG
)
{
free_command
(
cur_command
);
return
(
AMBIG_REDIR
);
}
if
(
cur_command
->
args
!=
NULL
)
{
return
(
handle_command
(
cur_command
,
xe
,
fd_in
,
proc
));
...
...
src/ft_exit.c
View file @
c4f2c88f
...
...
@@ -24,7 +24,7 @@ int parsing_error(int err_code, t_xe *xe)
(
void
)
err_msg
;
ft_putstr_fd
(
"minishell: syntax error: "
,
STDERR_FILENO
);
ft_putstr_fd
(
err_msg
[
err_code
],
STDERR_FILENO
);
ft_putstr_fd
(
err_msg
[
err_code
-
11
],
STDERR_FILENO
);
ft_putchar_fd
(
'\n'
,
STDERR_FILENO
);
xe
->
stat_loc
=
2
;
return
(
SUCCESS
);
...
...
@@ -39,7 +39,7 @@ int exec_error(int err_code, t_xe *xe)
(
void
)
err_msg
;
ft_putstr_fd
(
"minishell: command error: "
,
STDERR_FILENO
);
ft_putstr_fd
(
err_msg
[
err_code
-
8
],
STDERR_FILENO
);
ft_putstr_fd
(
err_msg
[
err_code
-
9
],
STDERR_FILENO
);
ft_putchar_fd
(
'\n'
,
STDERR_FILENO
);
// have to set stat_loc as well !!!
if
(
err_code
==
HOME_NOT_SET
)
...
...
@@ -54,11 +54,12 @@ int exec_error(int err_code, t_xe *xe)
static
const
char
*
err_msg
(
int
err_code
)
{
const
char
*
msg
[]
=
{
const
char
*
msg
[
5
]
=
{
"Minishell takes no argument"
,
"Memory allocation failure"
,
"Cannot write on standard output"
,
"Cannot read standard input (GNL error)"
};
"Cannot read standard input (GNL error)"
"Ambiguous redirection"
};
return
(
msg
[
err_code
]);
}
...
...
@@ -91,7 +92,7 @@ int ft_error(int ret, t_xe *xe)
if
(
ret
==
CLEAN_EXIT
||
ret
==
CHILD_EXIT
)
return
(
clean_and_exit
(
ret
,
xe
));
else
if
(
ret
>=
SQUOTE_MISSING
)
// temp
return
(
parsing_error
(
ret
-
10
,
xe
));
return
(
parsing_error
(
ret
,
xe
));
else
if
(
ret
>=
HOME_NOT_SET
)
return
(
exec_error
(
ret
,
xe
));
else
if
(
ret
>
CHILD_EXIT
)
...
...
src/parsing/parse_input.c
View file @
c4f2c88f
...
...
@@ -209,6 +209,6 @@ t_command *parse_one_command(t_xe *xe)
return
(
NULL
);
}
else
if
(
ret
==
AMBIG_REDIR
)
;
cur_command
->
redir_types
[
0
]
=
AMBIG
;
return
(
cur_command
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment