Skip to content

Commit 57735d1

Browse files
authored
Merge pull request #41 from 0bvim/fix/export-printing-shell-path
fix: remove print of variable path
2 parents 76a92ef + 2a01def commit 57735d1

2 files changed

Lines changed: 125 additions & 124 deletions

File tree

includes/minishell.h

Lines changed: 124 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# define MINISHELL_H
1515

1616
/* for read line (compile with -lreadline or just -l) */
17-
# include <stdio.h>
1817
# include <readline/history.h>
1918
# include <readline/readline.h>
19+
# include <stdio.h>
2020

2121
/* malloc, free, write, printf, getcwd, chdir, stat, lstat and others */
2222
# include <dirent.h>
@@ -51,7 +51,7 @@ extern volatile int g_last_signal;
5151

5252
/* enum and struct */
5353

54-
enum e_token
54+
enum e_token
5555
{
5656
ARGUMENT = 1,
5757
PIPE,
@@ -71,7 +71,7 @@ enum e_token
7171
EXEC
7272
};
7373

74-
enum e_type_match
74+
enum e_type_match
7575
{
7676
M_NONE,
7777
M_START,
@@ -81,133 +81,134 @@ enum e_type_match
8181

8282
typedef struct s_token
8383
{
84-
char *str;
85-
int type;
86-
char next_char;
87-
} t_token;
84+
char *str;
85+
int type;
86+
char next_char;
87+
} t_token;
8888

8989
typedef struct s_ast
9090
{
91-
struct s_ast *left;
92-
struct s_ast *right;
93-
t_list *exec;
94-
int type;
95-
int fd;
96-
} t_ast;
91+
struct s_ast *left;
92+
struct s_ast *right;
93+
t_list *exec;
94+
int type;
95+
int fd;
96+
} t_ast;
9797

9898
typedef struct s_cmd
9999
{
100-
char **args;
101-
char *cmd;
102-
} t_cmd;
103-
104-
//ENTRANCE
105-
void environ_initializer(void);
106-
char *static_pwd(char *new_pwd, int to_free);
107-
char *static_old_pwd(char *new_pwd, int to_free);
108-
char **environ_holder(char **new_environ, int to_free);
109-
void term_properties(int restore);
110-
111-
//BUILTINS
112-
char *malloc_pwd(void);
113-
int cd(char **args);
114-
int builtins_caller(char **args);
115-
int echo(char **args);
116-
int env(const char **args);
117-
int builtin_exit(char **args);
118-
int export(char **args);
119-
int pwd(const char **args);
120-
int unset(char **args);
121-
void clear_everything(void);
122-
char *key_name(const char *key_value);
123-
124-
//prompt
125-
char *prompt(void);
126-
int is_after_prompt(int is_after);
127-
void parser(char *input);
128-
129-
//pipe handling
130-
int handle_pipe(t_ast *node_pipe);
131-
132-
//handle redirs
133-
int heredoc_substitution(t_list *tokens);
134-
int is_redirect_in(int type);
135-
int is_redirect_out(int type);
136-
void dup_close_tmp(const int *tmp);
137-
void handle_redirs(t_ast *node_pipe);
138-
void fd_keeper(const int *tmp, int node_fd, int to_close);
139-
void dup_fun(t_ast *node, int outin);
140-
141-
//handle && and ||
142-
void handle_and_or(t_ast *node);
143-
144-
//handle block
145-
void handle_block(t_token *block);
146-
147-
//expands dollar sign variables
148-
void clear_tree(t_ast *root);
149-
150-
//AST
151-
t_ast *ast_constructor(t_list *tokens);
152-
int ast_split_node(t_ast *ast_node, t_list *tokens,
153-
t_element *el_to_split);
154-
t_ast *ast_holder(t_ast *root, int to_free);
155-
void panic_ast(int error, char *msg);
156-
t_element *search_and_or(t_list *tokens);
157-
t_element *search_pipe(t_list *tokens);
158-
t_element *search_redir(t_list *tokens);
159-
160-
//EXPANSIONS
161-
void expansions(t_list *tokens);
162-
void token_expansion(void *p_token);
163-
void heredoc_expansion(t_token *token);
164-
char **tokens_to_args(t_list *tokens);
165-
void asterisk(t_list *tokens, t_element *el);
100+
char **args;
101+
char *cmd;
102+
} t_cmd;
103+
104+
// ENTRANCE
105+
void environ_initializer(void);
106+
char *static_pwd(char *new_pwd, int to_free);
107+
char *static_old_pwd(char *new_pwd, int to_free);
108+
char **environ_holder(char **new_environ, int to_free);
109+
void term_properties(int restore);
110+
111+
// BUILTINS
112+
char *malloc_pwd(void);
113+
int cd(char **args);
114+
int builtins_caller(char **args);
115+
int echo(char **args);
116+
int env(const char **args);
117+
int builtin_exit(char **args);
118+
int export(char **args);
119+
int pwd(const char **args);
120+
int unset(char **args);
121+
void clear_everything(void);
122+
char *key_name(const char *key_value);
123+
124+
// prompt
125+
char *prompt(void);
126+
int is_after_prompt(int is_after);
127+
void parser(char *input);
128+
129+
// pipe handling
130+
int handle_pipe(t_ast *node_pipe);
131+
132+
// handle redirs
133+
int heredoc_substitution(t_list *tokens);
134+
int is_redirect_in(int type);
135+
int is_redirect_out(int type);
136+
void dup_close_tmp(const int *tmp);
137+
void handle_redirs(t_ast *node_pipe);
138+
void fd_keeper(const int *tmp, int node_fd, int to_close);
139+
void dup_fun(t_ast *node, int outin);
140+
141+
// handle && and ||
142+
void handle_and_or(t_ast *node);
143+
144+
// handle block
145+
void handle_block(t_token *block);
146+
147+
// expands dollar sign variables
148+
void clear_tree(t_ast *root);
149+
150+
// AST
151+
t_ast *ast_constructor(t_list *tokens);
152+
int ast_split_node(t_ast *ast_node, t_list *tokens,
153+
t_element *el_to_split);
154+
t_ast *ast_holder(t_ast *root, int to_free);
155+
void panic_ast(int error, char *msg);
156+
t_element *search_and_or(t_list *tokens);
157+
t_element *search_pipe(t_list *tokens);
158+
t_element *search_redir(t_list *tokens);
159+
160+
// EXPANSIONS
161+
void expansions(t_list *tokens);
162+
void token_expansion(void *p_token);
163+
void heredoc_expansion(t_token *token);
164+
char **tokens_to_args(t_list *tokens);
165+
void asterisk(t_list *tokens, t_element *el);
166166

167167
// execve
168-
void execution(t_ast *root);
169-
170-
//GRAMMAR CHECK
171-
int grammar_checker(t_list *tokens);
172-
int is_redirect(int type);
173-
int is_and_or(int type);
174-
int is_quotes(int type);
175-
int is_metacharacter(int type);
176-
int redir_and_or_pipe_rule(t_element *el);
177-
int block_rule(t_element *el);
178-
179-
//UTILS
180-
int ft_issymbol(char c);
181-
void ft_skip_spaces(const char **str);
182-
int which_token(const char *str);
183-
t_list *ft_lstsplit(t_list *lst, t_element *el);
184-
int last_exit_status(int exit_status);
185-
void pid_last_exit_status(pid_t pid);
186-
void ft_clear_list(char ***list);
187-
char *ft_getenv(const char *name);
188-
char *ft_getenv_or_blank(const char *name);
189-
void close_fds(void);
190-
int is_fork(int status);
191-
int ambiguous_error(void);
192-
193-
//TOKENIZER
194-
t_list *tokenizer(const char *str);
195-
t_list *token_list_holder(t_list *tokens, int to_free, int to_null);
196-
void free_token(void *p_token);
197-
void panic_tokenizer(int error, char *msg);
198-
void add_token(t_list *tokens, const char **start, const char **mover, \
199-
int token_type);
200-
int add_special_token(t_list *tokens,
201-
const char **start, const char **mover, int token_type);
202-
int quotes_validation(const char *str);
203-
int parenthesis_validation(const char *str);
204-
void trim_edges(void *content);
205-
206-
//SIGNALS
207-
void signals_initializer(void);
208-
void sigint_handler(int signal);
209-
int is_after_prompt(int is_after);
210-
int on_heredoc(int on_heredoc);
211-
void sigquit_case(void);
168+
void execution(t_ast *root);
169+
170+
// GRAMMAR CHECK
171+
int grammar_checker(t_list *tokens);
172+
int is_redirect(int type);
173+
int is_and_or(int type);
174+
int is_quotes(int type);
175+
int is_metacharacter(int type);
176+
int redir_and_or_pipe_rule(t_element *el);
177+
int block_rule(t_element *el);
178+
179+
// UTILS
180+
int ft_issymbol(char c);
181+
void ft_skip_spaces(const char **str);
182+
int which_token(const char *str);
183+
t_list *ft_lstsplit(t_list *lst, t_element *el);
184+
int last_exit_status(int exit_status);
185+
void pid_last_exit_status(pid_t pid);
186+
void ft_clear_list(char ***list);
187+
char *ft_getenv(const char *name);
188+
char *ft_getenv_or_blank(const char *name);
189+
void close_fds(void);
190+
int is_fork(int status);
191+
int ambiguous_error(void);
192+
193+
// TOKENIZER
194+
t_list *tokenizer(const char *str);
195+
t_list *token_list_holder(t_list *tokens, int to_free,
196+
int to_null);
197+
void free_token(void *p_token);
198+
void panic_tokenizer(int error, char *msg);
199+
void add_token(t_list *tokens, const char **start,
200+
const char **mover, int token_type);
201+
int add_special_token(t_list *tokens, const char **start,
202+
const char **mover, int token_type);
203+
int quotes_validation(const char *str);
204+
int parenthesis_validation(const char *str);
205+
void trim_edges(void *content);
206+
207+
// SIGNALS
208+
void signals_initializer(void);
209+
void sigint_handler(int signal);
210+
int is_after_prompt(int is_after);
211+
int on_heredoc(int on_heredoc);
212+
void sigquit_case(void);
212213

213214
#endif

src/builtins/export_sorting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static void format_and_print(const char *env_var)
2323
equal = ft_strchr(copy, '=');
2424
if (!equal)
2525
printf("declare -x %s\n", copy);
26-
else
26+
else if (ft_strncmp(copy, "_=", 2))
2727
{
2828
*equal = '\0';
2929
name = copy;

0 commit comments

Comments
 (0)