merge
This commit is contained in:
commit
c42abf75db
33 changed files with 429 additions and 371 deletions
1
42sh/42ShellTester/minishell_error
Normal file
1
42sh/42ShellTester/minishell_error
Normal file
|
|
@ -0,0 +1 @@
|
|||
[31m[38;5;34m.[0m
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/25 01:08:44 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/25 01:18:37 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
# include "libft.h"
|
||||
# include "builtin_read.h"
|
||||
|
||||
# define BT_EXPORT_LP (1 << 0)
|
||||
|
||||
|
||||
struct s_env_data
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/14 20:22:56 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 23:57:01 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/25 01:18:54 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/14 20:04:04 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/25 01:17:12 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/25 01:19:12 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -113,11 +113,8 @@ int cliopts_get(char **av, t_cliopts opt_map[], void *data)
|
|||
av++;
|
||||
while (av && *av)
|
||||
{
|
||||
if (ft_strcmp(*av, "--") == 0)
|
||||
{
|
||||
av++;
|
||||
if (ft_strcmp(*av, "-") == 0 || (ft_strcmp(*av, "--") == 0 && av++))
|
||||
break ;
|
||||
}
|
||||
else if ((*av)[0] == '-' && (*av)[1] == '-')
|
||||
{
|
||||
if (cliopts_parse_long(&av, opt_map, data))
|
||||
|
|
|
|||
304
42sh/log
Normal file
304
42sh/log
Normal file
|
|
@ -0,0 +1,304 @@
|
|||
Norme: ./src/builtin/bt_read_get.c
|
||||
Norme: ./src/builtin/builtin_echo.c
|
||||
Norme: ./src/builtin/bt_read_term.c
|
||||
Norme: ./src/builtin/builtin_exit.c
|
||||
Error (line 31): spaces at the end of line
|
||||
Norme: ./src/builtin/builtin_func.c
|
||||
Norme: ./src/builtin/builtin_cd.c
|
||||
Error (line 74): comment not well formatted
|
||||
Error (line 74): bad indentation
|
||||
Error (line 74): comment not well placed
|
||||
Norme: ./src/builtin/builtin_export.c
|
||||
Error (line 60): line has 88 characters
|
||||
Norme: ./src/builtin/builtin_hash.c
|
||||
Norme: ./src/builtin/builtin_history.c
|
||||
Norme: ./src/builtin/builtin_env.c
|
||||
Error (line 51): line has 82 characters
|
||||
Error (line 57): function builtin_env has 29 lines
|
||||
Norme: ./src/builtin/builtin_unset.c
|
||||
Norme: ./src/builtin/builtin_math.c
|
||||
Norme: ./src/builtin/error_msg.c
|
||||
Norme: ./src/builtin/builtin_unsetenv.c
|
||||
Norme: ./src/builtin/is_builtin.c
|
||||
Norme: ./src/builtin/builtin_setenv.c
|
||||
Norme: ./src/completion/c_find_abspath.c
|
||||
Norme: ./src/completion/c_find_binary.c
|
||||
Norme: ./src/completion/c_arrow.c
|
||||
Norme: ./src/builtin/builtin_read.c
|
||||
Norme: ./src/completion/c_clear.c
|
||||
Norme: ./src/completion/c_find_env.c
|
||||
Norme: ./src/completion/c_match.c
|
||||
Norme: ./src/completion/c_match_glob.c
|
||||
Norme: ./src/completion/c_init.c
|
||||
Norme: ./src/completion/c_match_update.c
|
||||
Norme: ./src/completion/c_find_files.c
|
||||
Norme: ./src/completion/c_misc.c
|
||||
Norme: ./src/completion/c_output.c
|
||||
Norme: ./src/completion/c_parser.c
|
||||
Norme: ./src/completion/c_sizing.c
|
||||
Norme: ./src/completion/c_printer.c
|
||||
Norme: ./src/exec/ast_free.c
|
||||
Norme: ./src/completion/c_terminal.c
|
||||
Norme: ./src/completion/completion.c
|
||||
Norme: ./src/exec/bad_fd.c
|
||||
Norme: ./src/exec/exec_and_if.c
|
||||
Norme: ./src/exec/exec_bang.c
|
||||
Norme: ./src/exec/exec_ampersand.c
|
||||
Norme: ./src/exec/exec_elif.c
|
||||
Norme: ./src/exec/exec_case_branch.c
|
||||
Norme: ./src/exec/exec_else.c
|
||||
Norme: ./src/exec/exec_or_if.c
|
||||
Norme: ./src/exec/exec_pipe.c
|
||||
Norme: ./src/completion/c_pathsolver.c
|
||||
Norme: ./src/exec/exec_semi.c
|
||||
Norme: ./src/exec/exec_leaf.c
|
||||
Norme: ./src/exec/exec_func.c
|
||||
Norme: ./src/exec/exec_reset.c
|
||||
Error (line 25): missing void in function exec_pushfds
|
||||
Error (line 37): missing void in function exec_popfds
|
||||
Norme: ./src/exec/fd_is_valid.c
|
||||
Norme: ./src/exec/exec_var.c
|
||||
Norme: ./src/exec/is_function.c
|
||||
Norme: ./src/exec/ft_exec.c
|
||||
Norme: ./src/exec/ft_findexec.c
|
||||
Norme: ./src/exec/mark_process_status.c
|
||||
Norme: ./src/exec/pfree_cond.c
|
||||
Norme: ./src/exec/pfree_cmd.c
|
||||
Norme: ./src/exec/pfree_list.c
|
||||
Norme: ./src/exec/pfree_func.c
|
||||
Norme: ./src/exec/pfree_subshell.c
|
||||
Norme: ./src/exec/node_copy.c
|
||||
Norme: ./src/exec/plaunch_brace.c
|
||||
Norme: ./src/exec/plaunch_empty.c
|
||||
Norme: ./src/exec/plaunch_builtin.c
|
||||
Norme: ./src/exec/plaunch_case.c
|
||||
Norme: ./src/exec/plaunch_function.c
|
||||
Norme: ./src/exec/plaunch_if.c
|
||||
Norme: ./src/exec/plaunch_for.c
|
||||
Norme: ./src/exec/plaunch_subshell.c
|
||||
Norme: ./src/exec/plaunch_until.c
|
||||
Norme: ./src/exec/plaunch_while.c
|
||||
Norme: ./src/exec/plaunch_file.c
|
||||
Norme: ./src/exec/process_setgroup.c
|
||||
Norme: ./src/exec/process_setsig.c
|
||||
Norme: ./src/exec/pset_brace.c
|
||||
Norme: ./src/exec/process_launch.c
|
||||
Norme: ./src/exec/process_redirect.c
|
||||
Norme: ./src/exec/pset_case.c
|
||||
Norme: ./src/exec/pset_for.c
|
||||
Norme: ./src/exec/pset_if.c
|
||||
Norme: ./src/exec/pset_subshell.c
|
||||
Norme: ./src/exec/pset_until.c
|
||||
Norme: ./src/exec/pset_while.c
|
||||
Norme: ./src/exec/pset_cmd.c
|
||||
Norme: ./src/exec/redir_copy.c
|
||||
Norme: ./src/exec/redir_free.c
|
||||
Norme: ./src/exec/redirect_dgreat.c
|
||||
Norme: ./src/exec/redirect_dless.c
|
||||
Norme: ./src/exec/process_set.c
|
||||
Norme: ./src/exec/redirect_great.c
|
||||
Error (line 25, col 7): Spacing after call to exit
|
||||
Norme: ./src/exec/redirect_less.c
|
||||
Norme: ./src/exec/redirect_greatand.c
|
||||
Norme: ./src/exec/redirect_lessand.c
|
||||
Norme: ./src/exec/set_exitstatus.c
|
||||
Norme: ./src/exec/token_to_argv.c
|
||||
Norme: ./src/glob/esc_print.c
|
||||
Norme: ./src/glob/command_getoutput.c
|
||||
Norme: ./src/glob/dir_glob.c
|
||||
Norme: ./src/glob/expand_esc.c
|
||||
Norme: ./src/glob/expand_home.c
|
||||
Norme: ./src/glob/expand_var.c
|
||||
Norme: ./src/glob/expand_brace.c
|
||||
Norme: ./src/glob/ft_strsplit_esc.c
|
||||
Norme: ./src/glob/gen_tab_esc.c
|
||||
Norme: ./src/glob/ft_strsplit_spe.c
|
||||
Norme: ./src/glob/is_char_esc.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_back.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_clear.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_copy.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_front.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_del.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_new.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_order.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_pushback.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_reverse.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_pushfront.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_size.c
|
||||
Norme: ./src/glob/glob.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_swap.c
|
||||
Norme: ./src/glob/lib_perso/ft_memrealloc.c
|
||||
Norme: ./src/glob/lib_perso/ft_ld_to_tab.c
|
||||
Norme: ./src/glob/lib_perso/ft_strjoinf.c
|
||||
Norme: ./src/glob/lib_perso/ft_strsubf.c
|
||||
Norme: ./src/glob/lib_perso/ft_tablen.c
|
||||
Norme: ./src/glob/lib_perso/ft_tabdel.c
|
||||
Norme: ./src/glob/tab_esc_copy.c
|
||||
Norme: ./src/glob/word_is_assignment.c
|
||||
Norme: ./src/hash_table/ft_add_hash.c
|
||||
Norme: ./src/hash_table/hash.c
|
||||
Norme: ./src/hash_table/hash_free.c
|
||||
Norme: ./src/hash_table/hash_str.c
|
||||
Norme: ./src/hash_table/is_hash.c
|
||||
Norme: ./src/glob/expand_bquote.c
|
||||
Norme: ./src/history/add_str_in_history.c
|
||||
Norme: ./src/history/history.c
|
||||
Norme: ./src/history/history_parsing_toolz_2.c
|
||||
Norme: ./src/history/history_parsing_toolz.c
|
||||
Norme: ./src/history/list_toolz.c
|
||||
Norme: ./src/job_control/builtin_bg.c
|
||||
Norme: ./src/history/history_parsing.c
|
||||
Norme: ./src/glob/match_pattern.c
|
||||
Norme: ./src/job_control/builtin_fg.c
|
||||
Norme: ./src/job_control/do_job_notification.c
|
||||
Norme: ./src/history/surch_in_history.c
|
||||
Norme: ./src/job_control/has_running_job.c
|
||||
Norme: ./src/job_control/has_stopped_job.c
|
||||
Norme: ./src/job_control/job_cmp_id.c
|
||||
Norme: ./src/job_control/job_format.c
|
||||
Norme: ./src/job_control/job_format_head.c
|
||||
Norme: ./src/job_control/job_free.c
|
||||
Norme: ./src/job_control/job_addprocess.c
|
||||
Norme: ./src/job_control/job_getprocess.c
|
||||
Norme: ./src/job_control/job_hup_all.c
|
||||
Norme: ./src/job_control/job_is_completed.c
|
||||
Norme: ./src/job_control/builtin_jobs.c
|
||||
Norme: ./src/job_control/job_is_stopped.c
|
||||
Norme: ./src/job_control/job_notify_change.c
|
||||
Norme: ./src/job_control/job_getrank.c
|
||||
Norme: ./src/job_control/job_run.c
|
||||
Norme: ./src/job_control/job_notify_new.c
|
||||
Norme: ./src/job_control/job_update_id.c
|
||||
Norme: ./src/job_control/job_remove.c
|
||||
Norme: ./src/job_control/job_update_status.c
|
||||
Norme: ./src/job_control/mark_job_as_running.c
|
||||
Norme: ./src/job_control/pprint_brace.c
|
||||
Norme: ./src/job_control/pprint_case.c
|
||||
Norme: ./src/job_control/pprint_cmd.c
|
||||
Norme: ./src/job_control/pprint_for.c
|
||||
Norme: ./src/job_control/pprint_function.c
|
||||
Norme: ./src/job_control/pprint_if.c
|
||||
Norme: ./src/job_control/pprint_subshell.c
|
||||
Norme: ./src/job_control/job_wait.c
|
||||
Norme: ./src/job_control/pprint_while.c
|
||||
Norme: ./src/job_control/process_cmp_pid.c
|
||||
Norme: ./src/job_control/pprint_until.c
|
||||
Norme: ./src/job_control/process_free.c
|
||||
Norme: ./src/job_control/put_job_in_background.c
|
||||
Norme: ./src/job_control/sigchld_handler.c
|
||||
Norme: ./src/job_control/sigint_handler.c
|
||||
Norme: ./src/job_control/sigtstp_handler.c
|
||||
Norme: ./src/job_control/sigttin_handler.c
|
||||
Norme: ./src/job_control/sigttou_handler.c
|
||||
Norme: ./src/lexer/get_lexer_stack.c
|
||||
Norme: ./src/job_control/put_job_in_foreground.c
|
||||
Error (line 27): bad indentation
|
||||
Error (line 27): C++ comment
|
||||
Norme: ./src/lexer/get_lexer_stack2.c
|
||||
Norme: ./src/lexer/do_lexer_routine.c
|
||||
Norme: ./src/lexer/get_state_global.c
|
||||
Norme: ./src/lexer/get_state_redir.c
|
||||
Norme: ./src/lexer/insert_newline.c
|
||||
Norme: ./src/lexer/keep_last_type.c
|
||||
Norme: ./src/lexer/isrw_delim.c
|
||||
Norme: ./src/lexer/lexer_backslash.c
|
||||
Norme: ./src/lexer/get_reserved_words.c
|
||||
Norme: ./src/lexer/lexer_curly_braces.c
|
||||
Norme: ./src/job_control/process_format.c
|
||||
Norme: ./src/lexer/lexer_default.c
|
||||
Norme: ./src/lexer/lexer_bquote.c
|
||||
Norme: ./src/lexer/lexer_destroy.c
|
||||
Norme: ./src/lexer/lexer_delim.c
|
||||
Norme: ./src/lexer/lexer_end.c
|
||||
Norme: ./src/lexer/lexer_heredoc.c
|
||||
Norme: ./src/lexer/lexer_dquote.c
|
||||
Norme: ./src/lexer/lexer_great.c
|
||||
Norme: ./src/lexer/lexer_init.c
|
||||
Norme: ./src/lexer/lexer_less.c
|
||||
Norme: ./src/lexer/lexer_newline.c
|
||||
Norme: ./src/lexer/lexer_lex.c
|
||||
Norme: ./src/lexer/lexer_quote.c
|
||||
Norme: ./src/lexer/lexer_paren.c
|
||||
Norme: ./src/lexer/lexer_number.c
|
||||
Norme: ./src/lexer/lexer_sep.c
|
||||
Norme: ./src/lexer/token_cmp_type.c
|
||||
Norme: ./src/lexer/token_free.c
|
||||
Norme: ./src/lexer/token_init.c
|
||||
Norme: ./src/lexer/lexer_word.c
|
||||
Norme: ./src/lexer/token_print.c
|
||||
Norme: ./src/line_editing/copy_cut_paste/underline_down.c
|
||||
Norme: ./src/lexer/token_append.c
|
||||
Norme: ./src/line_editing/control_features.c
|
||||
Norme: ./src/line_editing/copy_cut_paste/underline_end.c
|
||||
Norme: ./src/line_editing/copy_cut_paste/underline_function.c
|
||||
Norme: ./src/line_editing/copy_cut_paste/underline_home.c
|
||||
Norme: ./src/line_editing/copy_cut_paste/underline_left.c
|
||||
Norme: ./src/line_editing/copy_cut_paste/underline_reset.c
|
||||
Norme: ./src/line_editing/copy_cut_paste/underline_up.c
|
||||
Norme: ./src/line_editing/copy_cut_paste/underline_right.c
|
||||
Norme: ./src/line_editing/copy_cut_paste/copy_cut_paste.c
|
||||
Norme: ./src/line_editing/init_line/init_history.c
|
||||
Norme: ./src/line_editing/init_line/init_line.c
|
||||
Norme: ./src/line_editing/init_line/init_termcaps.c
|
||||
Norme: ./src/line_editing/lib_line_editing/ft_nb_line.c
|
||||
Norme: ./src/line_editing/ft_prompt.c
|
||||
Norme: ./src/line_editing/get_key.c
|
||||
Norme: ./src/line_editing/lib_line_editing/toolz.c
|
||||
Norme: ./src/line_editing/lib_line_editing/tool_line.c
|
||||
Norme: ./src/line_editing/lib_line_editing/tool_line_2.c
|
||||
Norme: ./src/line_editing/lib_line_editing/toolz_parseur.c
|
||||
Norme: ./src/line_editing/lib_line_editing/toolz_termcaps.c
|
||||
Norme: ./src/line_editing/lib_line_editing/toolz2.c
|
||||
Norme: ./src/line_editing/move_term/home_end.c
|
||||
Norme: ./src/line_editing/move_term/move_left_and_right.c
|
||||
Norme: ./src/line_editing/print_del_completion/completion.c
|
||||
Norme: ./src/line_editing/move_term/move_up_and_down.c
|
||||
Norme: ./src/line_editing/readline.c
|
||||
Norme: ./src/line_editing/resize.c
|
||||
Norme: ./src/main/data_exit.c
|
||||
Norme: ./src/line_editing/print_del_completion/queue.c
|
||||
Norme: ./src/main/data_singleton.c
|
||||
Norme: ./src/line_editing/move_term/move_to_word.c
|
||||
Norme: ./src/line_editing/print_del_completion/print_and_del.c
|
||||
Norme: ./src/main/data_init.c
|
||||
Norme: ./src/main/ft_putast.c
|
||||
Error (line 15): function ft_putast has 83 lines
|
||||
Error (line 15): declarations must be followed by one empty line in ft_putast
|
||||
Error (line 19): Empty line
|
||||
Error (line 52, col 21): missing space around ==
|
||||
Norme: ./src/main/shell_reset.c
|
||||
Norme: ./src/main/main.c
|
||||
Norme: ./src/main/shell_init.c
|
||||
Norme: ./src/parser/add_bang.c
|
||||
Norme: ./src/parser/add_case.c
|
||||
Norme: ./src/parser/add_condition.c
|
||||
Norme: ./src/parser/add_func.c
|
||||
Norme: ./src/parser/add_cmd.c
|
||||
Norme: ./src/parser/add_number.c
|
||||
Norme: ./src/parser/add_sep.c
|
||||
Norme: ./src/parser/add_loop.c
|
||||
Norme: ./src/parser/add_subshell.c
|
||||
Norme: ./src/parser/do_parser_routine.c
|
||||
Norme: ./src/parser/error_syntax.c
|
||||
Norme: ./src/parser/add_redir.c
|
||||
Norme: ./src/parser/build_tree.c
|
||||
Norme: ./src/parser/ft_parse.c
|
||||
Norme: ./src/parser/parser_destroy.c
|
||||
Norme: ./src/parser/parser_init.c
|
||||
Norme: ./src/parser/heredoc_parser.c
|
||||
Norme: ./src/parser/pop_stack.c
|
||||
Norme: ./src/parser/push_stack.c
|
||||
Norme: ./src/parser/produce_sym.c
|
||||
Norme: ./src/parser/redir_init.c
|
||||
Norme: ./src/parser/stack_init.c
|
||||
Norme: ./src/parser/sym_free.c
|
||||
Norme: ./src/parser/tree_func_free.c
|
||||
Norme: ./src/parser/tree_wrapper.c
|
||||
Norme: ./src/parser/read_stack.c
|
||||
Error (line 15): function read_state has 203 lines
|
||||
Norme: ./src/parser/aggregate_sym.c
|
||||
Error (line 401): C++ comment
|
||||
Error (line 402): C++ comment
|
||||
Error (line 403): C++ comment
|
||||
Norme: ./src/parser/eval_sym.c
|
||||
Error (line 1300): C++ comment
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[1;33m~[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[1;33m~[0m[31m[38;5;34m.[0m[31m[1;33m~[0m[31m[38;5;34m.[0m[31m[1;33m~[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;160mx[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;160mx[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[1;33m~[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;160mx[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m
|
||||
[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[1;33m~[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[1;33m~[0m[31m[38;5;34m.[0m[31m[1;33m~[0m[31m[38;5;34m.[0m[31m[1;33m~[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
|
|
@ -11,10 +11,10 @@
|
|||
[38;5;239m 01: export PATH=""[0m
|
||||
|
||||
STDIN:
|
||||
[38;5;239m 01: write_on_stdout "TOKEN201703241735"[0m
|
||||
[38;5;239m 01: write_on_stdout "TOKEN201703242314"[0m
|
||||
|
||||
STDOUT:
|
||||
[31m[38;5;160m FAILURE expected_to match_regex `TOKEN201703241735`[0m
|
||||
[31m[38;5;160m FAILURE expected_to match_regex `TOKEN201703242314`[0m
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
STDERR:
|
||||
|
|
@ -79,15 +79,15 @@
|
|||
05: SHELL=/bin/zsh
|
||||
06: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp
|
||||
07: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/
|
||||
08: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render
|
||||
08: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.UJksyURLXc/Render
|
||||
09: TERM_PROGRAM_VERSION=3.0.10
|
||||
10: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83
|
||||
10: TERM_SESSION_ID=w0t0p0:162D7F62-BEB1-405A-B3D5-E18A8A96E577
|
||||
11: ZSH=/Users/ariard/.oh-my-zsh
|
||||
12: USER=ariard
|
||||
13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners
|
||||
13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.zEo8Maujhn/Listeners
|
||||
14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0
|
||||
15: PAGER=less
|
||||
16: TMUX=/private/tmp/tmux-18965/default,73780,2
|
||||
16: TMUX=/private/tmp/tmux-18965/default,22653,2
|
||||
17: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches
|
||||
18: LSCOLORS=Gxfxcxdxbxegedabagacad
|
||||
19: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin
|
||||
|
|
@ -101,7 +101,7 @@
|
|||
27: SHLVL=4
|
||||
28: HOME=/Users/ariard
|
||||
29: COLORFGBG=7;0
|
||||
30: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83
|
||||
30: ITERM_SESSION_ID=w0t0p0:162D7F62-BEB1-405A-B3D5-E18A8A96E577
|
||||
31: LOGNAME=ariard
|
||||
32: LESS=-R
|
||||
33: LC_CTYPE=en_US.UTF-8
|
||||
|
|
@ -144,15 +144,15 @@
|
|||
05: SHELL=/bin/zsh
|
||||
06: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp
|
||||
07: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/
|
||||
08: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render
|
||||
08: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.UJksyURLXc/Render
|
||||
09: TERM_PROGRAM_VERSION=3.0.10
|
||||
10: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83
|
||||
10: TERM_SESSION_ID=w0t0p0:162D7F62-BEB1-405A-B3D5-E18A8A96E577
|
||||
11: ZSH=/Users/ariard/.oh-my-zsh
|
||||
12: USER=ariard
|
||||
13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners
|
||||
13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.zEo8Maujhn/Listeners
|
||||
14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0
|
||||
15: PAGER=less
|
||||
16: TMUX=/private/tmp/tmux-18965/default,73780,2
|
||||
16: TMUX=/private/tmp/tmux-18965/default,22653,2
|
||||
17: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches
|
||||
18: LSCOLORS=Gxfxcxdxbxegedabagacad
|
||||
19: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin
|
||||
|
|
@ -166,7 +166,7 @@
|
|||
27: SHLVL=4
|
||||
28: HOME=/Users/ariard
|
||||
29: COLORFGBG=7;0
|
||||
30: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83
|
||||
30: ITERM_SESSION_ID=w0t0p0:162D7F62-BEB1-405A-B3D5-E18A8A96E577
|
||||
31: LOGNAME=ariard
|
||||
32: LESS=-R
|
||||
33: LC_CTYPE=en_US.UTF-8
|
||||
|
|
@ -261,26 +261,24 @@
|
|||
|
||||
----------------------------------------------------------------
|
||||
|
||||
[37;1mminishell/builtins/env/005-set-variables[0m [31m[38;5;160m(FAILED)[0m
|
||||
[37;1mminishell/builtins/cd/options/002-oldpwd[0m [31m[38;5;160m(FAILED)[0m
|
||||
|
||||
Description:
|
||||
[38;5;239m The purpose of this test is to check that the builtin `env` can modify or set multiple environment variables before executing the given command.[0m
|
||||
|
||||
Before test:
|
||||
[38;5;239m 01: export VARTEST1="OLD_VALUE"[0m
|
||||
[38;5;239m The purpose of this test is to check that using `-` as first argument with the builtin `cd` results in moving the previous current directory.[0m
|
||||
|
||||
STDIN:
|
||||
[38;5;239m 01: env VARTEST1=TOKEN201703241735_1 VARTEST2=TOKEN201703241735_2 VARTEST3=TOKEN201703241735_3 ./display_env[0m
|
||||
[38;5;239m 01: cd /
|
||||
02: cd -
|
||||
03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd[0m
|
||||
|
||||
STDOUT:
|
||||
[31m[38;5;160m FAILURE expected_to match_regex `VARTEST1=TOKEN201703241735_1`[0m
|
||||
[31m[38;5;160m FAILURE expected_to match_regex `VARTEST2=TOKEN201703241735_2`[0m
|
||||
[31m[38;5;160m FAILURE expected_to match_regex `VARTEST3=TOKEN201703241735_3`[0m
|
||||
[38;5;239m (no output)[0m
|
||||
[31m[38;5;160m FAILURE expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD`[0m
|
||||
[38;5;239m 01: /Users/ariard
|
||||
02: PWD:/Users/ariard:PWD[0m
|
||||
|
||||
STDERR:
|
||||
[31m[38;5;160m FAILURE expected_to be_empty[0m
|
||||
[38;5;239m 01: ../../42sh: env: VARTEST1=TOKEN201703241735_1: No such file or directory[0m
|
||||
[31m[38;5;34m SUCCESS expected_to be_empty[0m
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
|
|
@ -308,31 +306,6 @@
|
|||
|
||||
----------------------------------------------------------------
|
||||
|
||||
[37;1mminishell/builtins/env/errors/002-illegal-option[0m [31m[38;5;160m(FAILED)[0m
|
||||
|
||||
Description:
|
||||
[38;5;239m The purpose of this test is to check that using the builtin `env` with an invalid option results in an error and failure exit status.[0m
|
||||
|
||||
Before test:
|
||||
[38;5;239m 01: rm -f -- "-w"[0m
|
||||
|
||||
STDIN:
|
||||
[38;5;239m 01: env -w[0m
|
||||
|
||||
STDOUT:
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
STDERR:
|
||||
[31m[38;5;34m SUCCESS expected_to_not be_empty[0m
|
||||
[31m[38;5;34m SUCCESS might match_regex `([Ii]nvalid|[Ii]llegal) (option|argument)`[0m
|
||||
[38;5;239m 01: env: invalid option -w
|
||||
02: ../../42sh: usage: env [-i] [name=value]... [utility [argument...]][0m
|
||||
|
||||
MISC:
|
||||
[31m[38;5;160m FAILURE expected_to_not exit_with_status `0`[0m
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
[37;1mminishell/builtins/exit/errors/001-too-many-args[0m [31m[38;5;160m(FAILED)[0m
|
||||
|
||||
Description:
|
||||
|
|
@ -340,10 +313,10 @@
|
|||
|
||||
STDIN:
|
||||
[38;5;239m 01: exit 21 42
|
||||
02: ./write_on_stdout TOKEN201703241735[0m
|
||||
02: ./write_on_stdout TOKEN201703242314[0m
|
||||
|
||||
STDOUT:
|
||||
[31m[38;5;160m FAILURE expected_to match_regex `TOKEN201703241735`[0m
|
||||
[31m[38;5;160m FAILURE expected_to match_regex `TOKEN201703242314`[0m
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
STDERR:
|
||||
|
|
@ -354,209 +327,6 @@
|
|||
MISC:
|
||||
[31m[38;5;160m FAILURE expected_to exit_with_status `0`[0m
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
[37;1mminishell/builtins/exit/errors/002-non-numeric-argument[0m [31m[38;5;160m(FAILED)[0m
|
||||
|
||||
Description:
|
||||
[38;5;239m The purpose of this test is to check that using a non-numeric argument with the builtin `exit` results in the Shell termination and an error on standard error.[0m
|
||||
|
||||
STDIN:
|
||||
[38;5;239m 01: exit abc
|
||||
02: ./write_on_stdout TOKEN201703241735[0m
|
||||
|
||||
STDOUT:
|
||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `TOKEN201703241735`[0m
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
STDERR:
|
||||
[31m[38;5;34m SUCCESS might_not be_empty[0m
|
||||
[31m[38;5;34m SUCCESS might match_regex `[Nn]umeric argument required`[0m
|
||||
[38;5;239m 01: ../../42sh: exit: numeric argument required[0m
|
||||
|
||||
MISC:
|
||||
[31m[38;5;160m FAILURE expected_to_not exit_with_status `0`[0m
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
[37;1mminishell/builtins/mixed/001-setenv-unsetenv[0m [31m[38;5;160m(FAILED)[0m
|
||||
|
||||
Description:
|
||||
[38;5;239m The purpose of this test is to check that setting and unsetting environment variable with the builtins `setenv` and `unsetenv` (or `export` and `unset`) works together.[0m
|
||||
|
||||
Before test:
|
||||
[38;5;239m 01: # unset all environment variables
|
||||
02: for VARIABLE in $(env | awk 'BEGIN {FS="="} {print $1}'); do unset "${VARIABLE}"; done;[0m
|
||||
|
||||
STDIN:
|
||||
[38;5;239m 01: setenv TEST1
|
||||
02: setenv TEST2
|
||||
03: unsetenv TEST1
|
||||
04: unsetenv TEST2
|
||||
05: ./display_env
|
||||
06:
|
||||
07: export TEST1
|
||||
08: export TEST2
|
||||
09: unset TEST1
|
||||
10: unset TEST2
|
||||
11: ./display_env[0m
|
||||
|
||||
STDOUT:
|
||||
[31m[38;5;160m FAILURE expected_to_not match_regex `TEST1=`[0m
|
||||
[31m[38;5;160m FAILURE expected_to_not match_regex `TEST2=`[0m
|
||||
[38;5;239m 01: ------------------------------
|
||||
02: _=../../42sh
|
||||
03: ?=0
|
||||
04: SHLVL=1
|
||||
05: TEST1=
|
||||
06: TEST2=
|
||||
07: ------------------------------
|
||||
08: TOTAL ENVIRONMENT VARIABLES: 5
|
||||
09: ------------------------------
|
||||
10: _=../../42sh
|
||||
11: ?=0
|
||||
12: SHLVL=1
|
||||
13: TEST1=
|
||||
14: TEST2=
|
||||
15: ------------------------------
|
||||
16: TOTAL ENVIRONMENT VARIABLES: 5[0m
|
||||
|
||||
STDERR:
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
[37;1mminishell/builtins/setenv/004-invalid-identifier[0m [31m[1;33m(WARNING)[0m
|
||||
|
||||
Description:
|
||||
[38;5;239m The purpose of this test is to check that using a wrong variable name with the builtin `setenv` (or `export`) results in error.[0m
|
||||
|
||||
STDIN:
|
||||
[38;5;239m 01: setenv 42
|
||||
02: export 42[0m
|
||||
|
||||
STDOUT:
|
||||
[31m[38;5;34m SUCCESS might be_empty[0m
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
STDERR:
|
||||
[31m[38;5;34m SUCCESS expected_to_not be_empty[0m
|
||||
[31m[1;33m WARNING might match_regex `(not.*identifier|must begin.*letter)`[0m
|
||||
[38;5;239m 01: ../../42sh: setenv: 42: invalid variable name
|
||||
02: ../../42sh: export: 42: invalid variable name[0m
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
[37;1mminishell/builtins/unsetenv/001-unsetenv-first-elem[0m [31m[38;5;160m(FAILED)[0m
|
||||
|
||||
Description:
|
||||
[38;5;239m This test was made to control if the Head of the env list was set correctly.
|
||||
So we unset all the environment variables inside the tester environment and set a new one.
|
||||
Thereafter we are unseting inside the tested shell. We are using env to check if the last head was remove correctly.[0m
|
||||
|
||||
Before test:
|
||||
[38;5;239m 01: # unset all environment variables
|
||||
02: for VARIABLE in $(env | awk 'BEGIN {FS="="} {print $1}'); do unset "${VARIABLE}"; done;
|
||||
03:
|
||||
04: export VARTEST="TOKEN201703241735"[0m
|
||||
|
||||
STDIN:
|
||||
[38;5;239m 01: unsetenv VARTEST
|
||||
02: unset VARTEST
|
||||
03: ./display_env[0m
|
||||
|
||||
STDOUT:
|
||||
[31m[38;5;160m FAILURE expected_to_not match_regex `VARTEST=`[0m
|
||||
[38;5;239m 01: ------------------------------
|
||||
02: VARTEST=TOKEN201703241735
|
||||
03: _=../../42sh
|
||||
04: ?=0
|
||||
05: SHLVL=1
|
||||
06: ------------------------------
|
||||
07: TOTAL ENVIRONMENT VARIABLES: 4[0m
|
||||
|
||||
STDERR:
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
[37;1mminishell/builtins/unsetenv/002-unsetenv-mult-envp[0m [31m[38;5;160m(FAILED)[0m
|
||||
|
||||
Description:
|
||||
[38;5;239m This test was made to check if we can unset multiple arguments.
|
||||
So we unset all the environment variables inside the tester environment and set a 3 new variables.
|
||||
Thereafter we are unseting all of them inside the tested shell.[0m
|
||||
|
||||
Before test:
|
||||
[38;5;239m 01: # unset all environment ariables
|
||||
02: for VARIABLE in $(env | awk 'BEGIN {FS="="} {print $1}'); do unset "${VARIABLE}"; done;
|
||||
03:
|
||||
04: export ONE="TOKEN201703241735_1"
|
||||
05: export TWO="TOKEN201703241735_2"
|
||||
06: export THREE="TOKEN201703241735_3"[0m
|
||||
|
||||
STDIN:
|
||||
[38;5;239m 01: unsetenv ONE
|
||||
02: unsetenv TWO
|
||||
03: unsetenv THREE
|
||||
04: unset ONE
|
||||
05: unset TWO
|
||||
06: unset THREE
|
||||
07: ./display_env[0m
|
||||
|
||||
STDOUT:
|
||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `ONE=`[0m
|
||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `TWO=`[0m
|
||||
[31m[38;5;160m FAILURE expected_to_not match_regex `THREE=`[0m
|
||||
[38;5;239m 01: ------------------------------
|
||||
02: THREE=TOKEN201703241735_3
|
||||
03: _=../../42sh
|
||||
04: ?=0
|
||||
05: SHLVL=1
|
||||
06: ------------------------------
|
||||
07: TOTAL ENVIRONMENT VARIABLES: 4[0m
|
||||
|
||||
STDERR:
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
[37;1mminishell/builtins/unsetenv/003-unsetenv-mult-envp-inline[0m [31m[38;5;160m(FAILED)[0m
|
||||
|
||||
Description:
|
||||
[38;5;239m This test was made to check if we can unset multiple arguments INLINE.
|
||||
So we unset all the environment variables inside the tester environment and set a 3 new variables.
|
||||
Thereafter we are unseting all of them INLINE inside the tested shell.[0m
|
||||
|
||||
Before test:
|
||||
[38;5;239m 01: # unset all variables
|
||||
02: for VARIABLE in $(env | awk 'BEGIN {FS="="} {print $1}'); do unset "${VARIABLE}"; done;
|
||||
03:
|
||||
04: export ONE="TOKEN201703241735_1"
|
||||
05: export TWO="TOKEN201703241735_2"
|
||||
06: export THREE="TOKEN201703241735_3"[0m
|
||||
|
||||
STDIN:
|
||||
[38;5;239m 01: unsetenv ONE TWO THREE
|
||||
02: unset ONE TWO THREE
|
||||
03: ./display_env[0m
|
||||
|
||||
STDOUT:
|
||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `ONE=`[0m
|
||||
[31m[38;5;160m FAILURE expected_to_not match_regex `TWO=`[0m
|
||||
[31m[38;5;160m FAILURE expected_to_not match_regex `THREE=`[0m
|
||||
[38;5;239m 01: ------------------------------
|
||||
02: THREE=TOKEN201703241735_3
|
||||
03: TWO=TOKEN201703241735_2
|
||||
04: _=../../42sh
|
||||
05: ?=0
|
||||
06: SHLVL=1
|
||||
07: ------------------------------
|
||||
08: TOTAL ENVIRONMENT VARIABLES: 5[0m
|
||||
|
||||
STDERR:
|
||||
[38;5;239m (no output)[0m
|
||||
|
||||
Total tests: 54
|
||||
Total failed tests: 12
|
||||
Total failed tests: 6
|
||||
Total pending tests: 0
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
ls | cat
|
||||
pwd ; cd
|
||||
ls # Da comment
|
||||
pwd
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
file1 <file1 ls
|
||||
|
|
@ -1 +0,0 @@
|
|||
ls ; pwd | |
|
||||
|
|
@ -1 +0,0 @@
|
|||
0
|
||||
4
42sh/sample/for.sh
Normal file
4
42sh/sample/for.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for i in hello bonjour salut comment
|
||||
do
|
||||
echo $i | cat -e
|
||||
done
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
for i in hello bonjour salut comment
|
||||
do
|
||||
while cat efezf
|
||||
do
|
||||
echo INSIDE
|
||||
done
|
||||
ls | cat
|
||||
done
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
hello() (
|
||||
echo HELLO
|
||||
)
|
||||
|
||||
hello
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
if ls
|
||||
if cat wef4eeef
|
||||
then
|
||||
pwd
|
||||
elif ls
|
||||
echo Conditon 1
|
||||
elif cat yulu
|
||||
then
|
||||
pwd
|
||||
elif ls
|
||||
then
|
||||
pwd
|
||||
else ls
|
||||
echo Condition 2
|
||||
else
|
||||
echo Condition 3
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
if cat wef4eeef
|
||||
then
|
||||
echo Conditon 1
|
||||
elif cat yulu
|
||||
then
|
||||
echo Condition 2
|
||||
else
|
||||
echo Condition 3
|
||||
fi
|
||||
|
|
@ -6,48 +6,44 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/03 11:57:53 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 23:03:58 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/25 00:52:32 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
#define CDOPT_L (1 << 0)
|
||||
#define CDOPT_P (1 << 1)
|
||||
#define HAS_CDOPT_P(x) (x & CD_OPT_P)
|
||||
#define HAS_CDOPT_L(x) (x & CD_OPT_L)
|
||||
#define BT_CD_L (1 << 0)
|
||||
#define BT_CD_P (1 << 1)
|
||||
#define CD_USAGE "usage: cd [-L|-P] [dir]"
|
||||
#define CDERR_1 "cd: no such file or directory: %s"
|
||||
#define CDERR_2 "cd: HOME not set"
|
||||
#define CDERR_3 "cd: too many arguments{eoc}"
|
||||
#define CDERR_2 "cd: %s not set"
|
||||
#define CDERR_3 "cd: too many arguments"
|
||||
|
||||
static g_cliopts g_cdotps =
|
||||
static t_cliopts g_cdopts[] =
|
||||
{
|
||||
{'P', NULL, CD_OPT_P, CD_OPT_L, NULL},
|
||||
{'L', NULL, CD_OPT_L, CD_OPT_P, NULL},
|
||||
{'P', NULL, BT_CD_P, BT_CD_L, NULL},
|
||||
{'L', NULL, BT_CD_L, BT_CD_P, NULL},
|
||||
{0, NULL, 0, 0, NULL},
|
||||
}
|
||||
};
|
||||
|
||||
static char *builtin_cd_special(char *const av[], char *const env[])
|
||||
static char *bt_cd_target(char *arg)
|
||||
{
|
||||
char *target;
|
||||
|
||||
if (!*av)
|
||||
if (!arg)
|
||||
{
|
||||
if (!(target = ft_getenv((char**)env, "HOME")))
|
||||
if (!(target = ft_getenv(data_singleton()->env, "HOME")))
|
||||
SH_ERR(CDERR_2, "HOME");
|
||||
}
|
||||
else if (ft_strcmp(arg, "-") == 0)
|
||||
{
|
||||
SH_ERR(CDERR_2);
|
||||
return (NULL);
|
||||
DG("doing -");
|
||||
if (!(target = ft_getenv(data_singleton()->env, "OLDPWD")))
|
||||
SH_ERR(CDERR_2, "OLDPWD");
|
||||
DG("found OLDPWD %s", target);
|
||||
}
|
||||
}
|
||||
else if (*av && *(av + 1))
|
||||
{
|
||||
SH_ERR(CDERR_3);
|
||||
return (NULL);
|
||||
}
|
||||
else if (ft_strcmp(*av, "-") == 0)
|
||||
target = ft_strdup(ft_getenv((char**)env, "OLDPWD"));
|
||||
else
|
||||
target = *av;
|
||||
target = arg;
|
||||
return (target);
|
||||
}
|
||||
|
||||
|
|
@ -56,32 +52,30 @@ void setwd(char *var)
|
|||
char *cwd;
|
||||
|
||||
cwd = getcwd(NULL, 0);
|
||||
builtin_setenv(path, (char*[4]){"setenv", var, cwd, NULL}, envp);
|
||||
builtin_setenv(NULL, (char*[]){"cd", var, cwd, NULL}, NULL);
|
||||
free(cwd);
|
||||
}
|
||||
|
||||
int builtin_cd(const char *path,
|
||||
char *const av[], char *const envp[])
|
||||
{
|
||||
int i;
|
||||
int opts;
|
||||
char *target;
|
||||
t_data_template data;
|
||||
|
||||
data->flag = CD_OPT_L;
|
||||
if (cliopts(av, g_cdopts, &data))
|
||||
i = builtin_cd_opts(av, &opts);
|
||||
(void)path;
|
||||
(void)envp;
|
||||
data.flag = BT_CD_L;
|
||||
if (cliopts_get((char**)av, g_cdopts, &data))
|
||||
return (ft_perror("cd") && SH_ERR(CD_USAGE));
|
||||
if (data.av_data[0] && data.av_data[1])
|
||||
return (SH_ERR(CDERR_3) && SH_ERR(CD_USAGE));
|
||||
if (!(target = bt_cd_target(*data.av_data)))
|
||||
return (1);
|
||||
setwd("OLDPWD");
|
||||
if (!(target = builtin_cd_special(av + i, envp)))
|
||||
return (1);
|
||||
if (chdir(target))
|
||||
{
|
||||
SH_ERR(CDERR_1, target);
|
||||
return (1);
|
||||
}
|
||||
else if (target != av[i])
|
||||
return (SH_ERR(CDERR_1, target));
|
||||
else if (target != *data.av_data)
|
||||
ft_printf("%s\n", target);
|
||||
setwd("PWD");
|
||||
if (!ft_strcmp(*(av + i), "-"))
|
||||
free(target);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/22 16:20:31 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/25 01:15:38 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/25 01:19:51 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/21 18:10:58 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:35:26 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
#define EXITERR_0 "exit: numeric argument required"
|
||||
#define EXITERR_1 "exit: too many argument required"
|
||||
|
||||
int builtin_exit(const char *path, char *const av[], char *const envp[])
|
||||
{
|
||||
|
|
@ -27,8 +28,11 @@ int builtin_exit(const char *path, char *const av[], char *const envp[])
|
|||
if (has_stopped_job() || has_running_job())
|
||||
return (SH_ERR("There are running and/or stopped jobs"));
|
||||
}
|
||||
if (av && av[1] && !ft_stris(av[1], ft_isdigit))
|
||||
if (av && av[1] && !ft_stris(av[1], ft_isdigit) && (status = 255))
|
||||
SH_ERR(EXITERR_0);
|
||||
else if (av && av[0] && av[1] && av[2])
|
||||
return (SH_ERR(EXITERR_1));
|
||||
else
|
||||
status = (av && av[1]) ?
|
||||
ft_atoi(av[1]) : ft_atoi(ft_getenv(data_singleton()->env, "?"));
|
||||
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
|
|
|
|||
|
|
@ -6,12 +6,15 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/24 19:33:00 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/25 00:57:26 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
#define BT_EXPORT_LP (1 << 0)
|
||||
#define EXPORT_USAGE "usage: export [name[=value] ...] or export -p"
|
||||
|
||||
static t_cliopts g_export_opts[] =
|
||||
{
|
||||
{'p', NULL, BT_EXPORT_LP, 0, NULL},
|
||||
|
|
@ -44,7 +47,7 @@ int builtin_export(
|
|||
(void)path;
|
||||
data.flag = 0;
|
||||
if (cliopts_get((char**)av, g_export_opts, &data))
|
||||
return (ft_perror("export") ? 1 : 1);
|
||||
return (ft_perror("export") && SH_ERR(EXPORT_USAGE));
|
||||
if (data.flag & BT_EXPORT_LP)
|
||||
return (bt_export_print());
|
||||
av = data.av_data;
|
||||
|
|
@ -57,7 +60,8 @@ int builtin_export(
|
|||
*(equal++) = 0;
|
||||
else
|
||||
equal = ft_getenv(data_singleton()->local_var, *av);
|
||||
data.flag += builtin_setenv("internal", (char*[]){"export", *av, equal}, envp);
|
||||
data.flag += builtin_setenv("internal", (char*[]){"export", *av,
|
||||
equal}, envp);
|
||||
builtin_unsetenv("internal", (char*[]){"local", *av, NULL}, NULL);
|
||||
av++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 16:23:51 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:30:45 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 23:08:13 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:14:52 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 15:12:42 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:29:53 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 20:09:13 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:29:00 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ int exec_reset_job(t_job *job)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int exec_pushfds()
|
||||
int exec_pushfds(void)
|
||||
{
|
||||
int i;
|
||||
t_exec *exec;
|
||||
|
|
@ -34,7 +34,7 @@ int exec_pushfds()
|
|||
return (0);
|
||||
}
|
||||
|
||||
int exec_popfds()
|
||||
int exec_popfds(void)
|
||||
{
|
||||
int i;
|
||||
t_exec *exec;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/06 22:03:53 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 20:09:09 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/25 00:57:59 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ int redirect_great(t_redir *redir)
|
|||
O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
|
||||
{
|
||||
SH_ERR("open(): %s", strerror(errno));
|
||||
exit (1);
|
||||
exit(1);
|
||||
}
|
||||
fd_replace(fdold, fdnew);
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 18:48:46 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:33:03 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
#define JOBS_USAGE "usage: jobs [-l] [id ...]"
|
||||
|
||||
t_cliopts g_jobs_opts[] =
|
||||
{
|
||||
{'l', NULL, JOBS_OPT_L, 0, NULL},
|
||||
|
|
@ -67,14 +69,11 @@ int builtin_jobs(const char *path, char *const av[], char *const envp[])
|
|||
(void)path;
|
||||
(void)envp;
|
||||
if (!SH_HAS_JOBC(data_singleton()->opts))
|
||||
{
|
||||
DG("no job control :(");
|
||||
return (SH_ERR("jobs: %s", SH_MSG_NOJOBC));
|
||||
}
|
||||
do_job_notification();
|
||||
ft_bzero(&data, sizeof(t_data_template));
|
||||
if (cliopts_get((char**)av, g_jobs_opts, &data))
|
||||
return (ft_perror("jobs"));
|
||||
return (ft_perror("jobs") && SH_ERR(JOBS_USAGE));
|
||||
if (!*data.av_data)
|
||||
bt_jobs_all(data.flag);
|
||||
else if (bt_jobs_spec(data.av_data, data.flag))
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/24 17:26:50 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:27:51 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
#define FGERR_0 "kill(SIGCONT) failed"
|
||||
|
||||
int put_job_in_foreground(t_job *j, int cont)
|
||||
{
|
||||
t_jobc *jobc;
|
||||
|
|
@ -23,8 +25,7 @@ int put_job_in_foreground(t_job *j, int cont)
|
|||
{
|
||||
tcsetattr(STDIN, TCSADRAIN, &j->tmodes);
|
||||
if (kill(-j->pgid, SIGCONT) < 0)
|
||||
DG("kill(SIGCONT) failed");
|
||||
//msg d'erreur a changer ici
|
||||
SH_ERR(FGERR_0);
|
||||
}
|
||||
job_wait(j->id);
|
||||
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/24 20:02:55 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/24 22:52:56 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -52,12 +52,12 @@ static int handle_instruction(t_list **token, t_btree **ast)
|
|||
else if (ret > 0)
|
||||
break ;
|
||||
}
|
||||
if (SH_IS_INTERACTIVE(data->opts) && data->lexer.str)
|
||||
ft_add_str_in_history(data->lexer.str);
|
||||
if (data->parser.state == SUCCESS && ft_exec(ast) < 0)
|
||||
exit(1);
|
||||
else if (data->parser.state != SUCCESS)
|
||||
set_exitstatus(1, 1);
|
||||
if (SH_IS_INTERACTIVE(data->opts) && data->lexer.str)
|
||||
ft_add_str_in_history(data->lexer.str);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/24 23:43:07 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/24 16:51:13 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:23:35 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/11 15:58:38 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/24 19:26:26 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:26:22 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -397,7 +397,3 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state)
|
|||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
// DG("aggregate head %s && sym %s", read_state(*head), read_state(*new_sym));
|
||||
// DG("MATH: %s", read_state(g_aggrematch[i].new_sym));
|
||||
// DG("stack after pop %s", read_state(*head));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/11 16:11:21 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/24 19:25:44 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/24 23:26:06 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -1296,5 +1296,3 @@ int eval_sym(t_list **stack, t_sym new_sym)
|
|||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
//DG("eval head %s && sym %s", read_state(*head), read_state(new_sym));
|
||||
|
|
|
|||
7
42sh/test.c
Normal file
7
42sh/test.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include "stdio.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("hello");
|
||||
return (0);
|
||||
}
|
||||
Loading…
Reference in a new issue