mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
(fix) Quote removal on heredoc limiters
This commit is contained in:
parent
ab861fc5c0
commit
5c53ebfa64
3 changed files with 45 additions and 5 deletions
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* redirect_from_words.c :+: :+: :+: */
|
/* redirect_from_words.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/14 17:31:35 by khais #+# #+# */
|
/* Created: 2025/04/14 17:31:35 by khais #+# #+# */
|
||||||
/* Updated: 2025/04/24 13:23:44 by khais ### ########.fr */
|
/* Updated: 2025/04/28 16:50:11 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "../../ft_errno.h"
|
#include "../../ft_errno.h"
|
||||||
#include "../../executing/here_doc/here_doc.h"
|
#include "../../executing/here_doc/here_doc.h"
|
||||||
#include "../cmd/cmd_destroy.h"
|
#include "../cmd/cmd_destroy.h"
|
||||||
|
#include "../remove_quotes/remove_quotes.h"
|
||||||
|
|
||||||
static t_redir_type redir_type_from_token_type(t_token_type type)
|
static t_redir_type redir_type_from_token_type(t_token_type type)
|
||||||
{
|
{
|
||||||
|
|
@ -68,6 +69,7 @@ t_redirect *redir_from_words(t_worddesc *operator,
|
||||||
t_worddesc *specifier, t_minishell *app)
|
t_worddesc *specifier, t_minishell *app)
|
||||||
{
|
{
|
||||||
t_redirect *redir;
|
t_redirect *redir;
|
||||||
|
t_worddesc *spec;
|
||||||
|
|
||||||
redir = redir_basic_setup(operator, specifier);
|
redir = redir_basic_setup(operator, specifier);
|
||||||
if (redir == NULL)
|
if (redir == NULL)
|
||||||
|
|
@ -75,8 +77,10 @@ t_redirect *redir_from_words(t_worddesc *operator,
|
||||||
if (redir->type == FT_HEREDOC)
|
if (redir->type == FT_HEREDOC)
|
||||||
{
|
{
|
||||||
redir->here_doc_eof = ft_strdup(specifier->word);
|
redir->here_doc_eof = ft_strdup(specifier->word);
|
||||||
redir->redirectee.dest = here_doc(specifier, STDIN_FILENO, app);
|
spec = remove_quotes(specifier);
|
||||||
worddesc_destroy(specifier);
|
worddesc_destroy(specifier);
|
||||||
|
redir->redirectee.dest = here_doc(spec, STDIN_FILENO, app);
|
||||||
|
worddesc_destroy(spec);
|
||||||
if (redir->redirectee.dest < 0)
|
if (redir->redirectee.dest < 0)
|
||||||
{
|
{
|
||||||
ft_errno(FT_EERRNO);
|
ft_errno(FT_EERRNO);
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* cmdgroup_remove_quotes.c :+: :+: :+: */
|
/* cmdgroup_remove_quotes.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/20 17:36:20 by khais #+# #+# */
|
/* Created: 2025/03/20 17:36:20 by khais #+# #+# */
|
||||||
/* Updated: 2025/04/22 15:37:15 by khais ### ########.fr */
|
/* Updated: 2025/04/28 16:43:53 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
36
test.sh
36
test.sh
|
|
@ -1559,4 +1559,40 @@ minishell: qwertyuiop: command not found
|
||||||
127
|
127
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
when_run <<EOF "simple quote removal for heredoc-limiters"
|
||||||
|
cat << 'hola'
|
||||||
|
test
|
||||||
|
hola
|
||||||
|
EOF
|
||||||
|
expecting <<EOF
|
||||||
|
test
|
||||||
|
EOF
|
||||||
|
|
||||||
|
when_run <<EOF "double quote removal for heredoc-limiters"
|
||||||
|
cat << "hola"
|
||||||
|
test
|
||||||
|
hola
|
||||||
|
EOF
|
||||||
|
expecting <<EOF
|
||||||
|
test
|
||||||
|
EOF
|
||||||
|
|
||||||
|
when_run <<EOF "nested quote removal for heredoc-limiters"
|
||||||
|
cat << "'hola'"
|
||||||
|
test
|
||||||
|
'hola'
|
||||||
|
EOF
|
||||||
|
expecting <<EOF
|
||||||
|
test
|
||||||
|
EOF
|
||||||
|
|
||||||
|
when_run <<EOF "absent quoted limiter for heredoc-limiters"
|
||||||
|
cat << "'hola'"
|
||||||
|
test
|
||||||
|
EOF
|
||||||
|
expecting <<"EOF"
|
||||||
|
minishell: warning: here-document delimited by end-of-file (wanted `'hola'')
|
||||||
|
test
|
||||||
|
EOF
|
||||||
|
|
||||||
finalize
|
finalize
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue