merged master where they fixed cd/env
This commit is contained in:
commit
3daf616256
5 changed files with 314 additions and 271 deletions
472
42sh/Makefile
472
42sh/Makefile
|
|
@ -13,7 +13,7 @@
|
||||||
NAME = minishell
|
NAME = minishell
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
FLAGS = -Wall -Wextra -Werror
|
FLAGS = -Wall -Wextra -Werror -fsanitize=address#-fvisibility=hidden
|
||||||
D_FLAGS = -g
|
D_FLAGS = -g
|
||||||
|
|
||||||
DELTA = $$(echo "$$(tput cols)-47"|bc)
|
DELTA = $$(echo "$$(tput cols)-47"|bc)
|
||||||
|
|
@ -29,224 +29,206 @@ INC_DIR = includes/
|
||||||
OBJ_DIR = objs/
|
OBJ_DIR = objs/
|
||||||
|
|
||||||
SRC_BASE = \
|
SRC_BASE = \
|
||||||
builtin/bt_cd_process_dotdot.c\
|
completion/c_pathsolver.c\
|
||||||
builtin/bt_env_opt.c\
|
completion/c_init.c\
|
||||||
builtin/bt_read_get.c\
|
completion/c_printer.c\
|
||||||
builtin/bt_read_term.c\
|
|
||||||
builtin/builtin_cd.c\
|
|
||||||
builtin/builtin_echo.c\
|
|
||||||
builtin/builtin_env.c\
|
|
||||||
builtin/builtin_exit.c\
|
|
||||||
builtin/builtin_export.c\
|
|
||||||
builtin/builtin_func.c\
|
|
||||||
builtin/builtin_hash.c\
|
|
||||||
builtin/builtin_history.c\
|
|
||||||
builtin/builtin_math.c\
|
|
||||||
builtin/builtin_read.c\
|
|
||||||
builtin/builtin_setenv.c\
|
|
||||||
builtin/builtin_unset.c\
|
|
||||||
builtin/builtin_unsetenv.c\
|
|
||||||
builtin/is_builtin.c\
|
|
||||||
completion/c_arrow.c\
|
|
||||||
completion/c_clear.c\
|
|
||||||
completion/c_find_abspath.c\
|
|
||||||
completion/c_find_binary.c\
|
completion/c_find_binary.c\
|
||||||
completion/c_find_env.c\
|
completion/c_find_env.c\
|
||||||
completion/c_find_files.c\
|
completion/c_clear.c\
|
||||||
completion/c_init.c\
|
|
||||||
completion/c_match.c\
|
|
||||||
completion/c_match_glob.c\
|
|
||||||
completion/c_match_update.c\
|
|
||||||
completion/c_misc.c\
|
|
||||||
completion/c_output.c\
|
|
||||||
completion/c_parser.c\
|
completion/c_parser.c\
|
||||||
completion/c_pathsolver.c\
|
completion/c_arrow.c\
|
||||||
completion/c_printer.c\
|
|
||||||
completion/c_sizing.c\
|
completion/c_sizing.c\
|
||||||
completion/c_terminal.c\
|
|
||||||
completion/completion.c\
|
completion/completion.c\
|
||||||
exec/ast_free.c\
|
completion/c_match_glob.c\
|
||||||
exec/bad_fd.c\
|
completion/c_find_files.c\
|
||||||
exec/exec_ampersand.c\
|
completion/c_terminal.c\
|
||||||
exec/exec_and_if.c\
|
completion/c_output.c\
|
||||||
exec/exec_bang.c\
|
completion/c_misc.c\
|
||||||
exec/exec_case_branch.c\
|
completion/c_match.c\
|
||||||
exec/exec_elif.c\
|
completion/c_match_update.c\
|
||||||
exec/exec_else.c\
|
completion/c_find_abspath.c\
|
||||||
exec/exec_func.c\
|
|
||||||
exec/exec_leaf.c\
|
|
||||||
exec/exec_or_if.c\
|
|
||||||
exec/exec_pipe.c\
|
|
||||||
exec/exec_reset.c\
|
|
||||||
exec/exec_semi.c\
|
|
||||||
exec/exec_var.c\
|
|
||||||
exec/fd_is_valid.c\
|
|
||||||
exec/ft_exec.c\
|
|
||||||
exec/ft_findexec.c\
|
|
||||||
exec/is_function.c\
|
|
||||||
exec/mark_process_status.c\
|
|
||||||
exec/node_copy.c\
|
|
||||||
exec/pfree_cmd.c\
|
|
||||||
exec/pfree_cond.c\
|
|
||||||
exec/pfree_func.c\
|
|
||||||
exec/pfree_list.c\
|
|
||||||
exec/pfree_subshell.c\
|
|
||||||
exec/plaunch_brace.c\
|
|
||||||
exec/plaunch_builtin.c\
|
|
||||||
exec/plaunch_case.c\
|
|
||||||
exec/plaunch_empty.c\
|
|
||||||
exec/plaunch_file.c\
|
|
||||||
exec/plaunch_for.c\
|
|
||||||
exec/plaunch_function.c\
|
|
||||||
exec/plaunch_if.c\
|
|
||||||
exec/plaunch_subshell.c\
|
|
||||||
exec/plaunch_until.c\
|
|
||||||
exec/plaunch_while.c\
|
|
||||||
exec/process_launch.c\
|
|
||||||
exec/process_redirect.c\
|
|
||||||
exec/process_set.c\
|
|
||||||
exec/process_setgroup.c\
|
|
||||||
exec/process_setsig.c\
|
|
||||||
exec/pset_brace.c\
|
|
||||||
exec/pset_case.c\
|
|
||||||
exec/pset_cmd.c\
|
|
||||||
exec/pset_for.c\
|
|
||||||
exec/pset_if.c\
|
|
||||||
exec/pset_subshell.c\
|
|
||||||
exec/pset_until.c\
|
|
||||||
exec/pset_while.c\
|
|
||||||
exec/redir_copy.c\
|
|
||||||
exec/redir_free.c\
|
|
||||||
exec/redirect_dgreat.c\
|
|
||||||
exec/redirect_dless.c\
|
|
||||||
exec/redirect_great.c\
|
|
||||||
exec/redirect_greatand.c\
|
|
||||||
exec/redirect_less.c\
|
|
||||||
exec/redirect_lessand.c\
|
|
||||||
exec/set_exitstatus.c\
|
|
||||||
exec/token_to_argv.c\
|
|
||||||
glob/command_getoutput.c\
|
|
||||||
glob/dir_glob.c\
|
|
||||||
glob/esc_print.c\
|
|
||||||
glob/expand_bquote.c\
|
|
||||||
glob/expand_brace.c\
|
|
||||||
glob/expand_esc.c\
|
|
||||||
glob/expand_home.c\
|
|
||||||
glob/expand_var.c\
|
|
||||||
glob/ft_strsplit_esc.c\
|
|
||||||
glob/ft_strsplit_spe.c\
|
|
||||||
glob/gen_tab_esc.c\
|
|
||||||
glob/glob.c\
|
|
||||||
glob/is_char_esc.c\
|
|
||||||
glob/lib_perso/ft_ld_back.c\
|
|
||||||
glob/lib_perso/ft_ld_clear.c\
|
|
||||||
glob/lib_perso/ft_ld_copy.c\
|
|
||||||
glob/lib_perso/ft_ld_del.c\
|
|
||||||
glob/lib_perso/ft_ld_front.c\
|
|
||||||
glob/lib_perso/ft_ld_new.c\
|
|
||||||
glob/lib_perso/ft_ld_order.c\
|
|
||||||
glob/lib_perso/ft_ld_pushback.c\
|
|
||||||
glob/lib_perso/ft_ld_pushfront.c\
|
|
||||||
glob/lib_perso/ft_ld_reverse.c\
|
|
||||||
glob/lib_perso/ft_ld_size.c\
|
|
||||||
glob/lib_perso/ft_ld_swap.c\
|
|
||||||
glob/lib_perso/ft_ld_to_tab.c\
|
|
||||||
glob/lib_perso/ft_memrealloc.c\
|
|
||||||
glob/lib_perso/ft_strjoinf.c\
|
|
||||||
glob/lib_perso/ft_strsubf.c\
|
|
||||||
glob/lib_perso/ft_tabdel.c\
|
|
||||||
glob/lib_perso/ft_tablen.c\
|
|
||||||
glob/match_pattern.c\
|
|
||||||
glob/tab_esc_copy.c\
|
|
||||||
glob/word_is_assignment.c\
|
|
||||||
hash_table/ft_add_hash.c\
|
|
||||||
hash_table/hash.c\
|
|
||||||
hash_table/hash_free.c\
|
|
||||||
hash_table/hash_str.c\
|
|
||||||
hash_table/is_hash.c\
|
|
||||||
history/add_str_in_history.c\
|
|
||||||
history/history.c\
|
|
||||||
history/history_parsing.c\
|
|
||||||
history/history_parsing_toolz.c\
|
|
||||||
history/history_parsing_toolz_2.c\
|
|
||||||
history/list_toolz.c\
|
|
||||||
history/surch_in_history.c\
|
history/surch_in_history.c\
|
||||||
job_control/builtin_bg.c\
|
history/history_parsing_toolz_2.c\
|
||||||
job_control/builtin_fg.c\
|
history/history_parsing_toolz.c\
|
||||||
job_control/builtin_jobs.c\
|
history/list_toolz.c\
|
||||||
job_control/do_job_notification.c\
|
history/add_str_in_history.c\
|
||||||
job_control/has_running_job.c\
|
history/history_parsing.c\
|
||||||
job_control/has_stopped_job.c\
|
history/history.c\
|
||||||
job_control/job_addprocess.c\
|
|
||||||
job_control/job_cmp_id.c\
|
|
||||||
job_control/job_format.c\
|
|
||||||
job_control/job_format_head.c\
|
|
||||||
job_control/job_free.c\
|
|
||||||
job_control/job_getprocess.c\
|
|
||||||
job_control/job_getrank.c\
|
|
||||||
job_control/job_hup_all.c\
|
|
||||||
job_control/job_is_completed.c\
|
|
||||||
job_control/job_is_stopped.c\
|
|
||||||
job_control/job_notify_change.c\
|
|
||||||
job_control/job_notify_new.c\
|
|
||||||
job_control/job_remove.c\
|
|
||||||
job_control/job_run.c\
|
|
||||||
job_control/job_update_id.c\
|
|
||||||
job_control/job_update_status.c\
|
|
||||||
job_control/job_wait.c\
|
|
||||||
job_control/mark_job_as_running.c\
|
|
||||||
job_control/pprint_brace.c\
|
|
||||||
job_control/pprint_case.c\
|
|
||||||
job_control/pprint_cmd.c\
|
|
||||||
job_control/pprint_for.c\
|
|
||||||
job_control/pprint_function.c\
|
|
||||||
job_control/pprint_if.c\
|
|
||||||
job_control/pprint_subshell.c\
|
|
||||||
job_control/pprint_until.c\
|
|
||||||
job_control/pprint_while.c\
|
job_control/pprint_while.c\
|
||||||
job_control/process_cmp_pid.c\
|
job_control/mark_job_as_running.c\
|
||||||
job_control/process_format.c\
|
job_control/pprint_case.c\
|
||||||
job_control/process_free.c\
|
job_control/job_notify_new.c\
|
||||||
job_control/put_job_in_background.c\
|
|
||||||
job_control/put_job_in_foreground.c\
|
|
||||||
job_control/sigchld_handler.c\
|
|
||||||
job_control/sigint_handler.c\
|
job_control/sigint_handler.c\
|
||||||
|
job_control/job_update_status.c\
|
||||||
|
job_control/job_format_head.c\
|
||||||
|
job_control/job_is_completed.c\
|
||||||
|
job_control/job_wait.c\
|
||||||
job_control/sigtstp_handler.c\
|
job_control/sigtstp_handler.c\
|
||||||
|
job_control/job_free.c\
|
||||||
|
job_control/pprint_for.c\
|
||||||
|
job_control/pprint_if.c\
|
||||||
|
job_control/job_hup_all.c\
|
||||||
|
job_control/put_job_in_foreground.c\
|
||||||
|
job_control/job_is_stopped.c\
|
||||||
|
job_control/process_free.c\
|
||||||
job_control/sigttin_handler.c\
|
job_control/sigttin_handler.c\
|
||||||
job_control/sigttou_handler.c\
|
job_control/sigttou_handler.c\
|
||||||
lexer/do_lexer_routine.c\
|
job_control/builtin_jobs.c\
|
||||||
lexer/get_lexer_stack.c\
|
job_control/process_cmp_pid.c\
|
||||||
lexer/get_lexer_stack2.c\
|
job_control/pprint_subshell.c\
|
||||||
lexer/get_reserved_words.c\
|
job_control/job_remove.c\
|
||||||
lexer/get_state_global.c\
|
job_control/builtin_bg.c\
|
||||||
lexer/get_state_redir.c\
|
job_control/job_run.c\
|
||||||
lexer/insert_newline.c\
|
job_control/has_stopped_job.c\
|
||||||
lexer/isrw_delim.c\
|
job_control/pprint_cmd.c\
|
||||||
lexer/keep_last_type.c\
|
job_control/job_cmp_id.c\
|
||||||
lexer/lexer_backslash.c\
|
job_control/pprint_brace.c\
|
||||||
lexer/lexer_bquote.c\
|
job_control/job_addprocess.c\
|
||||||
lexer/lexer_curly_braces.c\
|
job_control/job_update_id.c\
|
||||||
lexer/lexer_default.c\
|
job_control/do_job_notification.c\
|
||||||
|
job_control/job_getrank.c\
|
||||||
|
job_control/has_running_job.c\
|
||||||
|
job_control/process_format.c\
|
||||||
|
job_control/job_getprocess.c\
|
||||||
|
job_control/job_notify_change.c\
|
||||||
|
job_control/job_format.c\
|
||||||
|
job_control/put_job_in_background.c\
|
||||||
|
job_control/pprint_until.c\
|
||||||
|
job_control/pprint_function.c\
|
||||||
|
job_control/builtin_fg.c\
|
||||||
|
job_control/sigchld_handler.c\
|
||||||
|
parser/tree_func_free.c\
|
||||||
|
parser/parser_destroy.c\
|
||||||
|
parser/tree_wrapper.c\
|
||||||
|
parser/pop_stack.c\
|
||||||
|
parser/add_cmd.c\
|
||||||
|
parser/parser_init.c\
|
||||||
|
parser/aggregate_sym.c\
|
||||||
|
parser/redir_init.c\
|
||||||
|
parser/do_parser_routine.c\
|
||||||
|
parser/stack_init.c\
|
||||||
|
parser/add_number.c\
|
||||||
|
parser/add_func.c\
|
||||||
|
parser/add_loop.c\
|
||||||
|
parser/read_stack.c\
|
||||||
|
parser/push_stack.c\
|
||||||
|
parser/add_sep.c\
|
||||||
|
parser/ft_parse.c\
|
||||||
|
parser/add_condition.c\
|
||||||
|
parser/produce_sym.c\
|
||||||
|
parser/heredoc_parser.c\
|
||||||
|
parser/add_case.c\
|
||||||
|
parser/sym_free.c\
|
||||||
|
parser/add_subshell.c\
|
||||||
|
parser/build_tree.c\
|
||||||
|
parser/eval_sym.c\
|
||||||
|
parser/error_syntax.c\
|
||||||
|
parser/add_bang.c\
|
||||||
|
parser/add_redir.c\
|
||||||
|
main/data_exit.c\
|
||||||
|
main/ft_putast.c\
|
||||||
|
main/main.c\
|
||||||
|
main/shell_reset.c\
|
||||||
|
main/data_singleton.c\
|
||||||
|
main/data_init.c\
|
||||||
|
main/shell_init.c\
|
||||||
|
line_editing/lib_line_editing/toolz_termcaps.c\
|
||||||
|
line_editing/lib_line_editing/tool_line_2.c\
|
||||||
|
line_editing/lib_line_editing/tool_line.c\
|
||||||
|
line_editing/lib_line_editing/toolz.c\
|
||||||
|
line_editing/lib_line_editing/toolz_parseur.c\
|
||||||
|
line_editing/lib_line_editing/ft_nb_line.c\
|
||||||
|
line_editing/lib_line_editing/toolz2.c\
|
||||||
|
line_editing/resize.c\
|
||||||
|
line_editing/control_features.c\
|
||||||
|
line_editing/print_del_completion/queue.c\
|
||||||
|
line_editing/print_del_completion/completion.c\
|
||||||
|
line_editing/print_del_completion/print_and_del.c\
|
||||||
|
line_editing/get_key.c\
|
||||||
|
line_editing/ft_prompt.c\
|
||||||
|
line_editing/readline.c\
|
||||||
|
line_editing/move_term/move_up_and_down.c\
|
||||||
|
line_editing/move_term/home_end.c\
|
||||||
|
line_editing/move_term/move_to_word.c\
|
||||||
|
line_editing/move_term/move_left_and_right.c\
|
||||||
|
line_editing/init_line/init_termcaps.c\
|
||||||
|
line_editing/init_line/init_history.c\
|
||||||
|
line_editing/init_line/init_line.c\
|
||||||
|
line_editing/copy_cut_paste/underline_home.c\
|
||||||
|
line_editing/copy_cut_paste/underline_down.c\
|
||||||
|
line_editing/copy_cut_paste/underline_end.c\
|
||||||
|
line_editing/copy_cut_paste/underline_reset.c\
|
||||||
|
line_editing/copy_cut_paste/underline_function.c\
|
||||||
|
line_editing/copy_cut_paste/copy_cut_paste.c\
|
||||||
|
line_editing/copy_cut_paste/underline_right.c\
|
||||||
|
line_editing/copy_cut_paste/underline_up.c\
|
||||||
|
line_editing/copy_cut_paste/underline_left.c\
|
||||||
|
glob/expand_home.c\
|
||||||
|
glob/expand_bquote.c\
|
||||||
|
glob/dir_glob.c\
|
||||||
|
glob/ft_strsplit_esc.c\
|
||||||
|
glob/expand_var.c\
|
||||||
|
glob/glob.c\
|
||||||
|
glob/word_is_assignment.c\
|
||||||
|
glob/match_pattern.c\
|
||||||
|
glob/lib_perso/ft_ld_front.c\
|
||||||
|
glob/lib_perso/ft_ld_new.c\
|
||||||
|
glob/lib_perso/ft_ld_size.c\
|
||||||
|
glob/lib_perso/ft_tablen.c\
|
||||||
|
glob/lib_perso/ft_ld_pushfront.c\
|
||||||
|
glob/lib_perso/ft_ld_swap.c\
|
||||||
|
glob/lib_perso/ft_ld_order.c\
|
||||||
|
glob/lib_perso/ft_strsubf.c\
|
||||||
|
glob/lib_perso/ft_ld_reverse.c\
|
||||||
|
glob/lib_perso/ft_ld_to_tab.c\
|
||||||
|
glob/lib_perso/ft_tabdel.c\
|
||||||
|
glob/lib_perso/ft_strjoinf.c\
|
||||||
|
glob/lib_perso/ft_ld_del.c\
|
||||||
|
glob/lib_perso/ft_ld_back.c\
|
||||||
|
glob/lib_perso/ft_memrealloc.c\
|
||||||
|
glob/lib_perso/ft_ld_copy.c\
|
||||||
|
glob/lib_perso/ft_ld_pushback.c\
|
||||||
|
glob/lib_perso/ft_ld_clear.c\
|
||||||
|
glob/expand_brace.c\
|
||||||
|
glob/tab_esc_copy.c\
|
||||||
|
glob/ft_strsplit_spe.c\
|
||||||
|
glob/esc_print.c\
|
||||||
|
glob/expand_esc.c\
|
||||||
|
glob/is_char_esc.c\
|
||||||
|
glob/command_getoutput.c\
|
||||||
|
glob/gen_tab_esc.c\
|
||||||
lexer/lexer_delim.c\
|
lexer/lexer_delim.c\
|
||||||
lexer/lexer_destroy.c\
|
|
||||||
lexer/lexer_dquote.c\
|
|
||||||
lexer/lexer_end.c\
|
|
||||||
lexer/lexer_great.c\
|
|
||||||
lexer/lexer_heredoc.c\
|
|
||||||
lexer/lexer_init.c\
|
|
||||||
lexer/lexer_less.c\
|
|
||||||
lexer/lexer_lex.c\
|
|
||||||
lexer/lexer_newline.c\
|
|
||||||
lexer/lexer_number.c\
|
|
||||||
lexer/lexer_paren.c\
|
lexer/lexer_paren.c\
|
||||||
|
lexer/get_state_redir.c\
|
||||||
lexer/lexer_quote.c\
|
lexer/lexer_quote.c\
|
||||||
lexer/lexer_sep.c\
|
lexer/lexer_dquote.c\
|
||||||
lexer/lexer_word.c\
|
|
||||||
lexer/token_append.c\
|
|
||||||
lexer/token_cmp_type.c\
|
|
||||||
lexer/token_free.c\
|
lexer/token_free.c\
|
||||||
|
lexer/token_cmp_type.c\
|
||||||
|
lexer/lexer_sep.c\
|
||||||
|
lexer/lexer_heredoc.c\
|
||||||
lexer/token_init.c\
|
lexer/token_init.c\
|
||||||
|
lexer/lexer_less.c\
|
||||||
|
lexer/insert_newline.c\
|
||||||
|
lexer/get_lexer_stack2.c\
|
||||||
|
lexer/lexer_init.c\
|
||||||
|
lexer/keep_last_type.c\
|
||||||
|
lexer/isrw_delim.c\
|
||||||
|
lexer/lexer_lex.c\
|
||||||
|
lexer/lexer_destroy.c\
|
||||||
|
lexer/lexer_word.c\
|
||||||
|
lexer/lexer_newline.c\
|
||||||
|
lexer/get_lexer_stack.c\
|
||||||
|
lexer/lexer_great.c\
|
||||||
|
lexer/lexer_curly_braces.c\
|
||||||
|
lexer/lexer_end.c\
|
||||||
|
lexer/get_reserved_words.c\
|
||||||
|
lexer/do_lexer_routine.c\
|
||||||
|
lexer/token_append.c\
|
||||||
|
lexer/get_state_global.c\
|
||||||
|
lexer/lexer_bquote.c\
|
||||||
|
lexer/lexer_default.c\
|
||||||
lexer/token_print.c\
|
lexer/token_print.c\
|
||||||
|
<<<<<<< HEAD
|
||||||
line_editing/control_features.c\
|
line_editing/control_features.c\
|
||||||
line_editing/copy_cut_paste/copy_cut_paste.c\
|
line_editing/copy_cut_paste/copy_cut_paste.c\
|
||||||
line_editing/copy_cut_paste/underline_down.c\
|
line_editing/copy_cut_paste/underline_down.c\
|
||||||
|
|
@ -311,6 +293,92 @@ parser/stack_init.c\
|
||||||
parser/sym_free.c\
|
parser/sym_free.c\
|
||||||
parser/tree_func_free.c\
|
parser/tree_func_free.c\
|
||||||
parser/tree_wrapper.c
|
parser/tree_wrapper.c
|
||||||
|
=======
|
||||||
|
lexer/lexer_backslash.c\
|
||||||
|
lexer/lexer_number.c\
|
||||||
|
builtin/builtin_func.c\
|
||||||
|
builtin/builtin_export.c\
|
||||||
|
builtin/builtin_unsetenv.c\
|
||||||
|
builtin/builtin_setenv.c\
|
||||||
|
builtin/builtin_unset.c\
|
||||||
|
builtin/builtin_math.c\
|
||||||
|
builtin/bt_read_term.c\
|
||||||
|
builtin/builtin_echo.c\
|
||||||
|
builtin/builtin_hash.c\
|
||||||
|
builtin/bt_env_opt.c\
|
||||||
|
builtin/builtin_exit.c\
|
||||||
|
builtin/builtin_cd.c\
|
||||||
|
builtin/builtin_read.c\
|
||||||
|
builtin/is_builtin.c\
|
||||||
|
builtin/bt_read_get.c\
|
||||||
|
builtin/builtin_history.c\
|
||||||
|
builtin/builtin_env.c\
|
||||||
|
exec/pset_brace.c\
|
||||||
|
exec/pset_if.c\
|
||||||
|
exec/pfree_func.c\
|
||||||
|
exec/plaunch_subshell.c\
|
||||||
|
exec/pset_case.c\
|
||||||
|
exec/exec_ampersand.c\
|
||||||
|
exec/exec_and_if.c\
|
||||||
|
exec/exec_var.c\
|
||||||
|
exec/exec_case_branch.c\
|
||||||
|
exec/redirect_greatand.c\
|
||||||
|
exec/redir_copy.c\
|
||||||
|
exec/redir_free.c\
|
||||||
|
exec/token_to_argv.c\
|
||||||
|
exec/exec_pipe.c\
|
||||||
|
exec/pfree_cond.c\
|
||||||
|
exec/pset_for.c\
|
||||||
|
exec/pset_until.c\
|
||||||
|
exec/exec_func.c\
|
||||||
|
exec/exec_or_if.c\
|
||||||
|
exec/node_copy.c\
|
||||||
|
exec/pfree_list.c\
|
||||||
|
exec/redirect_dless.c\
|
||||||
|
exec/exec_bang.c\
|
||||||
|
exec/redirect_dgreat.c\
|
||||||
|
exec/mark_process_status.c\
|
||||||
|
exec/plaunch_for.c\
|
||||||
|
exec/is_function.c\
|
||||||
|
exec/pset_while.c\
|
||||||
|
exec/exec_else.c\
|
||||||
|
exec/ast_free.c\
|
||||||
|
exec/exec_semi.c\
|
||||||
|
exec/plaunch_while.c\
|
||||||
|
exec/bad_fd.c\
|
||||||
|
exec/exec_leaf.c\
|
||||||
|
exec/plaunch_if.c\
|
||||||
|
exec/plaunch_case.c\
|
||||||
|
exec/process_redirect.c\
|
||||||
|
exec/process_setgroup.c\
|
||||||
|
exec/ft_exec.c\
|
||||||
|
exec/set_exitstatus.c\
|
||||||
|
exec/plaunch_brace.c\
|
||||||
|
exec/plaunch_empty.c\
|
||||||
|
exec/redirect_great.c\
|
||||||
|
exec/process_set.c\
|
||||||
|
exec/exec_reset.c\
|
||||||
|
exec/plaunch_until.c\
|
||||||
|
exec/pset_cmd.c\
|
||||||
|
exec/redirect_lessand.c\
|
||||||
|
exec/ft_findexec.c\
|
||||||
|
exec/redirect_less.c\
|
||||||
|
exec/pset_subshell.c\
|
||||||
|
exec/fd_is_valid.c\
|
||||||
|
exec/exec_elif.c\
|
||||||
|
exec/plaunch_builtin.c\
|
||||||
|
exec/pfree_subshell.c\
|
||||||
|
exec/plaunch_file.c\
|
||||||
|
exec/process_setsig.c\
|
||||||
|
exec/plaunch_function.c\
|
||||||
|
exec/process_launch.c\
|
||||||
|
exec/pfree_cmd.c\
|
||||||
|
hash_table/ft_add_hash.c\
|
||||||
|
hash_table/is_hash.c\
|
||||||
|
hash_table/hash.c\
|
||||||
|
hash_table/hash_free.c\
|
||||||
|
hash_table/hash_str.c
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE))
|
SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE))
|
||||||
OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o))
|
OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o))
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* bt_cd_process_dotdot.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2017/03/25 03:54:22 by ariard #+# #+# */
|
|
||||||
/* Updated: 2017/03/25 21:19:07 by ariard ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "minishell.h"
|
|
||||||
|
|
||||||
#define CDERR_0 "cd : %s: No such file or directory"
|
|
||||||
#define CDERR_1 "cd : %s: Permission denied"
|
|
||||||
#define CDERR_2 "cd : %s: Not a directory"
|
|
||||||
#define CDERR_3 "cd : unable to proceed: %s"
|
|
||||||
|
|
||||||
int bt_cd_process_dotdot(char *target)
|
|
||||||
{
|
|
||||||
if (access(target, F_OK))
|
|
||||||
return (SH_ERR(CDERR_0, target));
|
|
||||||
if (access(target, X_OK))
|
|
||||||
return (SH_ERR(CDERR_1, target));
|
|
||||||
if (!is_directory(target))
|
|
||||||
return (SH_ERR(CDERR_2, target));
|
|
||||||
if (chdir(target))
|
|
||||||
return (SH_ERR(CDERR_3, target));
|
|
||||||
setwd("PWD");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
@ -19,6 +19,10 @@
|
||||||
#define CD_USAGE "usage: cd [-L|-P] [dir]"
|
#define CD_USAGE "usage: cd [-L|-P] [dir]"
|
||||||
#define CDERR_0 "cd: too many arguments"
|
#define CDERR_0 "cd: too many arguments"
|
||||||
#define CDERR_1 "cd %s not set"
|
#define CDERR_1 "cd %s not set"
|
||||||
|
#define CDERR_2 "cd : %s: No such file or directory"
|
||||||
|
#define CDERR_3 "cd : %s: Permission denied"
|
||||||
|
#define CDERR_4 "cd : %s: Not a directory"
|
||||||
|
#define CDERR_5 "cd : unable to proceed: %s"
|
||||||
|
|
||||||
static t_cliopts g_cdopts[] =
|
static t_cliopts g_cdopts[] =
|
||||||
{
|
{
|
||||||
|
|
@ -27,43 +31,42 @@ static t_cliopts g_cdopts[] =
|
||||||
{0, NULL, 0, 0, NULL, 0},
|
{0, NULL, 0, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *cd_operand_exist(char *arg)
|
int cd_file_autorisations(char *target, int flag)
|
||||||
{
|
{
|
||||||
char *target;
|
(void)flag;
|
||||||
|
if (access(target, F_OK))
|
||||||
target = NULL;
|
return (SH_ERR(CDERR_2, target));
|
||||||
if (!arg)
|
if (!is_directory(target))
|
||||||
{
|
return (SH_ERR(CDERR_3, target));
|
||||||
if (!(target = ft_strdup(ft_getenv(data_singleton()->env, "HOME"))))
|
if (access(target, X_OK))
|
||||||
SH_ERR(CDERR_1, "HOME");
|
return (SH_ERR(CDERR_4, target));
|
||||||
}
|
if (chdir(target))
|
||||||
return (target);
|
return (SH_ERR(CDERR_5, target));
|
||||||
|
setwd("PWD");
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *cd_operand_begin(char *arg)
|
static char *cd_operand_exist(char *arg)
|
||||||
{
|
{
|
||||||
char *target;
|
char *tget;
|
||||||
|
|
||||||
if (arg && arg[0])
|
tget = NULL;
|
||||||
|
if (!arg)
|
||||||
{
|
{
|
||||||
if (arg[0] == '/')
|
if (!(tget = ft_strdup(ft_getenv(data_singleton()->env, "HOME"))))
|
||||||
target = ft_strdup(arg);
|
return (SH_ERR(CDERR_1, "HOME") ? NULL : NULL);
|
||||||
else if (!ft_strncmp(arg, "./", 2) || !ft_strncmp(arg, "../", 3)
|
|
||||||
|| !ft_strcmp(arg, ".") || !ft_strcmp(arg, ".."))
|
|
||||||
target = ft_str3join(ft_getenv(data_singleton()->env,
|
|
||||||
"PWD"), "/", arg);
|
|
||||||
else if (!ft_strcmp(arg, "-"))
|
|
||||||
{
|
|
||||||
if (!(target = ft_strdup(ft_getenv(data_singleton()->env,
|
|
||||||
"OLDPWD"))))
|
|
||||||
SH_ERR(CDERR_1, "OLDPWD");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
target = ft_str3join(".", "/", arg);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
target = arg;
|
{
|
||||||
return (target);
|
if (!ft_strcmp(arg, "-"))
|
||||||
|
{
|
||||||
|
if (!(tget = ft_strdup(ft_getenv(data_singleton()->env, "OLDPWD"))))
|
||||||
|
return (SH_ERR(CDERR_1, "OLDPWD") ? NULL : NULL);
|
||||||
|
return (tget);
|
||||||
|
}
|
||||||
|
return (tget = ft_strdup(arg));
|
||||||
|
}
|
||||||
|
return (tget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setwd(char *var)
|
void setwd(char *var)
|
||||||
|
|
@ -72,7 +75,7 @@ void setwd(char *var)
|
||||||
|
|
||||||
cwd = getcwd(NULL, 0);
|
cwd = getcwd(NULL, 0);
|
||||||
builtin_setenv(NULL, (char*[]){"cd", var, cwd, NULL}, NULL);
|
builtin_setenv(NULL, (char*[]){"cd", var, cwd, NULL}, NULL);
|
||||||
free(cwd);
|
ft_strdel(&cwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int builtin_cd(const char *path, char *const av[],
|
int builtin_cd(const char *path, char *const av[],
|
||||||
|
|
@ -86,17 +89,16 @@ int builtin_cd(const char *path, char *const av[],
|
||||||
(void)envp;
|
(void)envp;
|
||||||
(void)path;
|
(void)path;
|
||||||
data.flag = CD_OPT_L;
|
data.flag = CD_OPT_L;
|
||||||
ret = 0;
|
|
||||||
if (cliopts_get((char **)av, g_cdopts, &data))
|
if (cliopts_get((char **)av, g_cdopts, &data))
|
||||||
return (1);
|
return (1);
|
||||||
if (data.av_data[0] && data.av_data[1])
|
if (data.av_data[0] && data.av_data[1])
|
||||||
return (SH_ERR(CDERR_0) && SH_ERR(CD_USAGE));
|
return (SH_ERR(CDERR_0) && SH_ERR(CD_USAGE));
|
||||||
if (!(target = cd_operand_exist(*data.av_data)))
|
if (!(target = cd_operand_exist(*data.av_data)))
|
||||||
target = cd_operand_begin(*data.av_data);
|
return (1);
|
||||||
oldpwd = getcwd(NULL, 0);
|
oldpwd = getcwd(NULL, 0);
|
||||||
if ((ret = bt_cd_process_dotdot(target)))
|
if (!(ret = cd_file_autorisations(target, data.flag)))
|
||||||
builtin_setenv(NULL, (char*[]){"cd", "OLDPWD", oldpwd, NULL}, NULL);
|
builtin_setenv(NULL, (char*[]){"cd", "OLDPWD", oldpwd, NULL}, NULL);
|
||||||
free(target);
|
ft_strdel(&target);
|
||||||
free(oldpwd);
|
ft_strdel(&oldpwd);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,15 @@ static t_cliopts g_env_opts[] =
|
||||||
|
|
||||||
static int bt_env_getcustom(char ***av, t_env_data *data)
|
static int bt_env_getcustom(char ***av, t_env_data *data)
|
||||||
{
|
{
|
||||||
|
char **split;
|
||||||
|
|
||||||
if (!av || !*av || !data)
|
if (!av || !*av || !data)
|
||||||
return (1);
|
return (1);
|
||||||
while (**av && ft_strchr(**av, '='))
|
while (**av && ft_strchr(**av, '='))
|
||||||
{
|
{
|
||||||
|
split = ft_strsplit(**av, '=');
|
||||||
|
bt_env_opt_u(split[0], data);
|
||||||
|
ft_tabdel(&split);
|
||||||
data->custom_env = ft_sstradd(data->custom_env, **av);
|
data->custom_env = ft_sstradd(data->custom_env, **av);
|
||||||
++(*av);
|
++(*av);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,10 +89,10 @@ int ft_del(char **str, size_t *pos)
|
||||||
size_t tmp;
|
size_t tmp;
|
||||||
|
|
||||||
tmp = *pos;
|
tmp = *pos;
|
||||||
|
if (!(*str && *pos < ft_strlen(*str)))
|
||||||
|
return (0);
|
||||||
if (!(*str = ft_remove_imput(*str, tmp)))
|
if (!(*str = ft_remove_imput(*str, tmp)))
|
||||||
return (-1);
|
return (-1);
|
||||||
if (!(*str && *pos < ft_strlen(*str) + 1))
|
|
||||||
return (0);
|
|
||||||
if (*pos)
|
if (*pos)
|
||||||
{
|
{
|
||||||
--(*pos);
|
--(*pos);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue