-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
single quote doit etre egal a command not found
- Loading branch information
Showing
9 changed files
with
50 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# By: zhabri <[email protected]> +#+ +:+ +#+ # | ||
# +#+#+#+#+#+ +#+ # | ||
# Created: 2022/09/04 08:44:16 by zhabri #+# #+# # | ||
# Updated: 2023/01/10 11:24:53 by zhabri ### ########.fr # | ||
# Updated: 2023/01/12 14:29:11 by zhabri ### ########.fr # | ||
# # | ||
# **************************************************************************** # | ||
|
||
|
@@ -56,6 +56,7 @@ SRCS = add_cmd.c \ | |
utils.c \ | ||
utils_bis.c \ | ||
utils_cd.c \ | ||
utils_dollar.c \ | ||
utils_exit.c \ | ||
utils_export.c \ | ||
utils_export_bis.c \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: zhabri <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/01/03 10:49:26 by zhabri #+# #+# */ | ||
/* Updated: 2023/01/10 13:01:15 by zhabri ### ########.fr */ | ||
/* Updated: 2023/01/12 15:27:17 by zhabri ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -30,6 +30,7 @@ int builtin(char *cmd) | |
} | ||
i++; | ||
} | ||
printf("jsp: %s\n", cmd_split[0]); | ||
free_tab(cmd_split); | ||
return (-1); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,17 @@ | |
/* By: zhabri <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/12/06 13:06:15 by zhabri #+# #+# */ | ||
/* Updated: 2023/01/12 11:12:07 by zhabri ### ########.fr */ | ||
/* Updated: 2023/01/12 15:17:15 by zhabri ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft/includes/libft.h" | ||
#include "minishell.h" | ||
|
||
static void infile_exception(t_token *var) | ||
{ | ||
int i; | ||
char *second_part; | ||
char *tmp; | ||
char **arg_split; | ||
|
||
arg_split = ft_split_quotes_keep_sep(var->arg, "<>|"); | ||
|
@@ -26,15 +26,17 @@ static void infile_exception(t_token *var) | |
i = 1; | ||
while (arg_split[i]) | ||
{ | ||
tmp = ft_strjoin("\"", arg_split[i]); | ||
tmp = ft_strjoinf(tmp, "\""); | ||
second_part = ft_strjoinf(second_part, tmp); | ||
free(tmp); | ||
infile_exception_tmp(&second_part, arg_split[i]); | ||
i++; | ||
} | ||
} | ||
free(var->arg); | ||
var->arg = ft_strjoin(arg_split[0], second_part); | ||
if (arg_split[0][0] == '<' || arg_split[0][0] == '>' || \ | ||
arg_split[0][0] == '|') | ||
var->arg = ft_strjoinf(ft_strjoin("\"", arg_split[0]), "\""); | ||
else | ||
var->arg = ft_strdup(arg_split[0]); | ||
var->arg = ft_strjoinf(var->arg, second_part); | ||
free(second_part); | ||
free_tab(arg_split); | ||
} | ||
|
@@ -116,7 +118,10 @@ void find_var(t_token *token, char *input) | |
i++; | ||
len++; | ||
} | ||
token->arg = ft_substr(input, token->str_idx + 1, len); | ||
if (len == 0 && (input[i] == '\'' || input[i] == '\"')) | ||
token->arg = ft_strdup("-"); | ||
else | ||
token->arg = ft_substr(input, token->str_idx + 1, len); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: zhabri <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/12/01 11:49:37 by zhabri #+# #+# */ | ||
/* Updated: 2023/01/10 12:53:16 by zhabri ### ########.fr */ | ||
/* Updated: 2023/01/12 15:21:41 by zhabri ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -39,6 +39,7 @@ void events(t_list **head) | |
{ | ||
scan_heredocs(); | ||
get_cmd(); | ||
print_cmds(); | ||
if (!g_glob->sig_int) | ||
pipex(); | ||
unlink_heredocs(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: zhabri <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/27 20:30:45 by zhabri #+# #+# */ | ||
/* Updated: 2023/01/12 14:12:34 by zhabri ### ########.fr */ | ||
/* Updated: 2023/01/12 14:28:56 by zhabri ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -146,6 +146,7 @@ char *get_path(char *cmd, bool shaone); | |
void handle_sigint(void); | ||
void handle_sigquit(void); | ||
void ignore_sig(int sig); | ||
void infile_exception_tmp(char **second_part, char *arg_split); | ||
void init_children_pid(int **children_pid, int size); | ||
t_cmd *init_cmd_token(int in, int out, char *str, bool reset); | ||
void init_ft_chdir(t_list **pwd, t_list **old_pwd, char **ret); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: zhabri <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/12/26 16:35:44 by zhabri #+# #+# */ | ||
/* Updated: 2023/01/10 13:05:55 by zhabri ### ########.fr */ | ||
/* Updated: 2023/01/12 15:29:21 by zhabri ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -40,13 +40,16 @@ void child(t_cmd *cmd, int *pipes, int *children_pid) | |
char **envp; | ||
char **cmd_split; | ||
|
||
ft_printf("0- cmd: %s\n", cmd->str); | ||
if (cmd->fd_in != -1 && cmd->fd_out != -1 \ | ||
&& cmd->str && cmd->str[0] != '\0') | ||
{ | ||
g_glob->exit_ret = 1; | ||
cmd_split = ft_split_quotes(cmd->str, " \t"); | ||
cmd_split[0] = remove_quotes(cmd_split[0]); | ||
ft_printf("1- cmd: %s\n", cmd_split[0]); | ||
cmd_split[0] = get_path(cmd_split[0], false); | ||
ft_printf("2- cmd: %s\n", cmd_split[0]); | ||
exit_on_error(cmd, cmd_split, pipes, children_pid); | ||
dup_and_close(cmd, pipes); | ||
envp = envp_list_to_tab(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: zhabri <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/12/05 13:24:06 by zhabri #+# #+# */ | ||
/* Updated: 2023/01/10 11:37:26 by zhabri ### ########.fr */ | ||
/* Updated: 2023/01/12 15:21:09 by zhabri ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -48,7 +48,7 @@ void print_cmds(void) | |
if (!(((t_cmd *)cmd->content)->str)) | ||
printf("cmd is NULL\n"); | ||
else | ||
printf("cmd: %d\n", (((t_cmd *)cmd->content)->str[0])); | ||
printf("cmd: %s\n", (((t_cmd *)cmd->content)->str)); | ||
} | ||
cmd = cmd->next; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: zhabri <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/12/13 13:16:51 by zhabri #+# #+# */ | ||
/* Updated: 2023/01/09 11:17:04 by zhabri ### ########.fr */ | ||
/* Updated: 2023/01/12 14:53:57 by zhabri ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* utils_dollar.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: zhabri <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/01/12 14:26:56 by zhabri #+# #+# */ | ||
/* Updated: 2023/01/12 14:28:25 by zhabri ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
void infile_exception_tmp(char **second_part, char *arg_split) | ||
{ | ||
char *tmp; | ||
|
||
tmp = ft_strjoinf(ft_strjoin("\"", arg_split), "\""); | ||
*second_part = ft_strjoinf(*second_part, tmp); | ||
free(tmp); | ||
} |