exit error + nomre last

This commit is contained in:
Antoine Riard 2017-03-24 23:35:59 +01:00
parent 66ec5363ca
commit 6a5d2aa13e
25 changed files with 379 additions and 316 deletions

View file

@ -0,0 +1 @@
.

304
42sh/log Normal file
View 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

View file

@ -1,4 +1,4 @@
...x...~......xx....~.~.~..........xxx....xxx...~.xxx.
...x...~......xx....~.~.~......x....x.....x...........
----------------------------------------------------------------
@ -11,10 +11,10 @@
 01: export PATH=""
STDIN:
 01: write_on_stdout "TOKEN201703241735"
 01: write_on_stdout "TOKEN201703242314"
STDOUT:
 FAILURE expected_to match_regex `TOKEN201703241735`
 FAILURE expected_to match_regex `TOKEN201703242314`
 (no output)
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 @@
----------------------------------------------------------------
minishell/builtins/env/005-set-variables (FAILED)
minishell/builtins/cd/options/002-oldpwd (FAILED)
Description:
 The purpose of this test is to check that the builtin `env` can modify or set multiple environment variables before executing the given command.
Before test:
 01: export VARTEST1="OLD_VALUE"
 The purpose of this test is to check that using `-` as first argument with the builtin `cd` results in moving the previous current directory.
STDIN:
 01: env VARTEST1=TOKEN201703241735_1 VARTEST2=TOKEN201703241735_2 VARTEST3=TOKEN201703241735_3 ./display_env
 01: cd /
02: cd -
03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd
STDOUT:
 FAILURE expected_to match_regex `VARTEST1=TOKEN201703241735_1`
 FAILURE expected_to match_regex `VARTEST2=TOKEN201703241735_2`
 FAILURE expected_to match_regex `VARTEST3=TOKEN201703241735_3`
 (no output)
 FAILURE expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD`
 01: /Users/ariard
02: PWD:/Users/ariard:PWD
STDERR:
 FAILURE expected_to be_empty
 01: ../../42sh: env: VARTEST1=TOKEN201703241735_1: No such file or directory
 SUCCESS expected_to be_empty
 (no output)
----------------------------------------------------------------
@ -308,31 +306,6 @@
----------------------------------------------------------------
minishell/builtins/env/errors/002-illegal-option (FAILED)
Description:
 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.
Before test:
 01: rm -f -- "-w"
STDIN:
 01: env -w
STDOUT:
 (no output)
STDERR:
 SUCCESS expected_to_not be_empty
 SUCCESS might match_regex `([Ii]nvalid|[Ii]llegal) (option|argument)`
 01: env: invalid option -w
02: ../../42sh: usage: env [-i] [name=value]... [utility [argument...]]
MISC:
 FAILURE expected_to_not exit_with_status `0`
----------------------------------------------------------------
minishell/builtins/exit/errors/001-too-many-args (FAILED)
Description:
@ -340,10 +313,10 @@
STDIN:
 01: exit 21 42
02: ./write_on_stdout TOKEN201703241735
02: ./write_on_stdout TOKEN201703242314
STDOUT:
 FAILURE expected_to match_regex `TOKEN201703241735`
 FAILURE expected_to match_regex `TOKEN201703242314`
 (no output)
STDERR:
@ -354,209 +327,6 @@
MISC:
 FAILURE expected_to exit_with_status `0`
----------------------------------------------------------------
minishell/builtins/exit/errors/002-non-numeric-argument (FAILED)
Description:
 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.
STDIN:
 01: exit abc
02: ./write_on_stdout TOKEN201703241735
STDOUT:
 SUCCESS expected_to_not match_regex `TOKEN201703241735`
 (no output)
STDERR:
 SUCCESS might_not be_empty
 SUCCESS might match_regex `[Nn]umeric argument required`
 01: ../../42sh: exit: numeric argument required
MISC:
 FAILURE expected_to_not exit_with_status `0`
----------------------------------------------------------------
minishell/builtins/mixed/001-setenv-unsetenv (FAILED)
Description:
 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.
Before test:
 01: # unset all environment variables
02: for VARIABLE in $(env | awk 'BEGIN {FS="="} {print $1}'); do unset "${VARIABLE}"; done;
STDIN:
 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
STDOUT:
 FAILURE expected_to_not match_regex `TEST1=`
 FAILURE expected_to_not match_regex `TEST2=`
 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
STDERR:
 (no output)
----------------------------------------------------------------
minishell/builtins/setenv/004-invalid-identifier (WARNING)
Description:
 The purpose of this test is to check that using a wrong variable name with the builtin `setenv` (or `export`) results in error.
STDIN:
 01: setenv 42
02: export 42
STDOUT:
 SUCCESS might be_empty
 (no output)
STDERR:
 SUCCESS expected_to_not be_empty
 WARNING might match_regex `(not.*identifier|must begin.*letter)`
 01: ../../42sh: setenv: 42: invalid variable name
02: ../../42sh: export: 42: invalid variable name
----------------------------------------------------------------
minishell/builtins/unsetenv/001-unsetenv-first-elem (FAILED)
Description:
 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.
Before test:
 01: # unset all environment variables
02: for VARIABLE in $(env | awk 'BEGIN {FS="="} {print $1}'); do unset "${VARIABLE}"; done;
03:
04: export VARTEST="TOKEN201703241735"
STDIN:
 01: unsetenv VARTEST
02: unset VARTEST
03: ./display_env
STDOUT:
 FAILURE expected_to_not match_regex `VARTEST=`
 01: ------------------------------
02: VARTEST=TOKEN201703241735
03: _=../../42sh
04: ?=0
05: SHLVL=1
06: ------------------------------
07: TOTAL ENVIRONMENT VARIABLES: 4
STDERR:
 (no output)
----------------------------------------------------------------
minishell/builtins/unsetenv/002-unsetenv-mult-envp (FAILED)
Description:
 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.
Before test:
 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"
STDIN:
 01: unsetenv ONE
02: unsetenv TWO
03: unsetenv THREE
04: unset ONE
05: unset TWO
06: unset THREE
07: ./display_env
STDOUT:
 SUCCESS expected_to_not match_regex `ONE=`
 SUCCESS expected_to_not match_regex `TWO=`
 FAILURE expected_to_not match_regex `THREE=`
 01: ------------------------------
02: THREE=TOKEN201703241735_3
03: _=../../42sh
04: ?=0
05: SHLVL=1
06: ------------------------------
07: TOTAL ENVIRONMENT VARIABLES: 4
STDERR:
 (no output)
----------------------------------------------------------------
minishell/builtins/unsetenv/003-unsetenv-mult-envp-inline (FAILED)
Description:
 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.
Before test:
 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"
STDIN:
 01: unsetenv ONE TWO THREE
02: unset ONE TWO THREE
03: ./display_env
STDOUT:
 SUCCESS expected_to_not match_regex `ONE=`
 FAILURE expected_to_not match_regex `TWO=`
 FAILURE expected_to_not match_regex `THREE=`
 01: ------------------------------
02: THREE=TOKEN201703241735_3
03: TWO=TOKEN201703241735_2
04: _=../../42sh
05: ?=0
06: SHLVL=1
07: ------------------------------
08: TOTAL ENVIRONMENT VARIABLES: 5
STDERR:
 (no output)
Total tests: 54
Total failed tests: 12
Total failed tests: 6
Total pending tests: 0

View file

@ -1,2 +1,2 @@
ls | cat
pwd ; cd
ls # Da comment
pwd

View file

@ -1 +0,0 @@
file1 <file1 ls

View file

@ -1 +0,0 @@
ls ; pwd | |

View file

@ -1 +0,0 @@
0

4
42sh/sample/for.sh Normal file
View file

@ -0,0 +1,4 @@
for i in hello bonjour salut comment
do
echo $i | cat -e
done

View file

@ -1,8 +0,0 @@
for i in hello bonjour salut comment
do
while cat efezf
do
echo INSIDE
done
ls | cat
done

View file

@ -1,3 +1,5 @@
hello() (
echo HELLO
)
hello

View file

@ -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

View file

@ -1,9 +0,0 @@
if cat wef4eeef
then
echo Conditon 1
elif cat yulu
then
echo Condition 2
else
echo Condition 3
fi

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/22 16:20:31 by gwojda #+# #+# */
/* Updated: 2017/03/24 17:59:00 by jhalford ### ########.fr */
/* Updated: 2017/03/24 23:22:19 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -65,17 +65,14 @@ int builtin_env(const char *path,
(void)envp;
if (bt_env_parse(&data, (char**)argv))
return (ft_perror("env") && SH_ERR("usage: %s", ENV_USAGE));
DG();
if (!*data.av_data)
{
DG();
ft_sstrprint(data.custom_env, '\n');
ft_putchar('\n');
return (0);
}
else if ((pid = fork()) == 0)
{
DG();
if (!(path = ft_strchr(data.av_data[0], '/') ?
ft_strdup(data.av_data[0]) : ft_hash(data.av_data[0]))
|| access(path, F_OK) != 0)

View file

@ -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,9 +28,12 @@ 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);
status = (av && av[1]) ?
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))
tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes);

View file

@ -6,7 +6,7 @@
/* 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/24 23:32:04 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -57,7 +57,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++;
}

View file

@ -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;

View file

@ -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/24 23:28:30 by ariard ### ########.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);

View file

@ -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))

View file

@ -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);
}

View file

@ -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 */
/* */
/* ************************************************************************** */

View file

@ -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));

View file

@ -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
View file

@ -0,0 +1,7 @@
#include "stdio.h"
int main(void)
{
printf("hello");
return (0);
}