From b107d53463033d41c22bd8e13569385361c1a82a Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 03:19:22 +0200 Subject: [PATCH 01/18] [redirection] :sheep: close #206 --- 42sh/src/exec/redirect_greatand.c | 4 ++-- 42sh/src/exec/redirect_lessand.c | 4 ++-- 42sh/src/job_control/job_update_status.c | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/42sh/src/exec/redirect_greatand.c b/42sh/src/exec/redirect_greatand.c index 10c979ac..e241ba40 100644 --- a/42sh/src/exec/redirect_greatand.c +++ b/42sh/src/exec/redirect_greatand.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */ -/* Updated: 2017/03/25 00:58:22 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 03:18:37 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,7 @@ int redirect_greatand(t_redir *redir) if (fdold > 9) return (bad_fd(fdold)); if (fd_is_valid(fdold, O_WRONLY | O_RDWR)) - fd_replace(fdold, fdnew); + dup2(fdold, fdnew); else return (bad_fd(fdold)); return (0); diff --git a/42sh/src/exec/redirect_lessand.c b/42sh/src/exec/redirect_lessand.c index 0f4f5928..1be9e62c 100644 --- a/42sh/src/exec/redirect_lessand.c +++ b/42sh/src/exec/redirect_lessand.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:11:18 by jhalford #+# #+# */ -/* Updated: 2017/03/21 16:33:43 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 03:18:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,7 @@ int redirect_lessand(t_redir *redir) if (fdold > 9) return (bad_fd(fdold)); if (fd_is_valid(fdold, O_RDONLY | O_RDWR)) - fd_replace(fdold, fdnew); + dup2(fdold, fdnew); else return (bad_fd(fdold)); return (0); diff --git a/42sh/src/job_control/job_update_status.c b/42sh/src/job_control/job_update_status.c index 4467696e..8b00a02b 100644 --- a/42sh/src/job_control/job_update_status.c +++ b/42sh/src/job_control/job_update_status.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */ -/* Updated: 2017/03/27 03:07:57 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 03:17:54 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,6 @@ void job_update_status(void) if ((pid = waitpid(WAIT_ANY, &status, WUNTRACED | WNOHANG)) == -1 && errno != ECHILD) SH_ERR("waitpid(): %s", strerror(errno)); - DG("wait trigger pid=%i", pid); if (pid <= 1 || mark_process_status(pid, status)) break ; } From b2615bc266b87c954faf243d129f9008effcaf9d Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 27 Mar 2017 03:48:30 +0200 Subject: [PATCH 02/18] case loop no more leaks --- 42sh/21sh_error | 235 ---- 42sh/42ShellTester/file | 10 + 42sh/42ShellTester/log | 436 ++---- 42sh/42sh_error | 2501 ---------------------------------- 42sh/Makefile | 4 +- 42sh/file | 1 + 42sh/file1 | 20 + 42sh/other | 1 + 42sh/src/exec/plaunch_case.c | 4 +- 42sh/src/exec/pset_case.c | 2 +- 42sh/test.c | 10 + 42sh/test.sh | 1 + 42sh/test/fifi | 0 42sh/test1 | 24 + 14 files changed, 200 insertions(+), 3049 deletions(-) delete mode 100644 42sh/21sh_error create mode 100644 42sh/42ShellTester/file delete mode 100644 42sh/42sh_error create mode 100644 42sh/file create mode 100644 42sh/file1 create mode 100644 42sh/other create mode 100644 42sh/test.c create mode 100644 42sh/test.sh create mode 100644 42sh/test/fifi create mode 100644 42sh/test1 diff --git a/42sh/21sh_error b/42sh/21sh_error deleted file mode 100644 index 4e43d0d5..00000000 --- a/42sh/21sh_error +++ /dev/null @@ -1,235 +0,0 @@ -.x....................xxx...xxxx..x. - ----------------------------------------------------------------- - -21sh/misc/002-simple-command-line (FAILED) - - Description: - The purpose of this test is to check that the Shell is able to execute a simple command line that contains separators `;`, pipes `|`, and a right redirection `>`. - - Before test: - 01: rm -rf "./size" - 02: rm -rf "TOKEN201703241734" - 03: echo '^'$(echo TOKEN201703241734_FILE_TOKEN201703241734_STDOUT | wc -c)'$' > "./size" - - STDIN: - 01: mkdir TOKEN201703241734 ; cd TOKEN201703241734 ; touch TOKEN201703241734_FILE ; ls -1 ; ls | cat | wc -c > TOKEN201703241734_STDOUT ; cat TOKEN201703241734_STDOUT - - STDOUT: - SUCCESS expected_to match_regex `TOKEN201703241734_FILE$` - FAILURE expected_to match_each_regex_of_file `./size` - 01: TOKEN201703241734_FILE - 02: 98839 redirect_great.c 24 3 1 - 03: 23 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -21sh/redirections/outputs/truncating/001-creates-file-if-not-exits (FAILED) - - Description: - The right redirection `>` opens the file with the oflag `O_CREAT` so that the file is created if it does not exists. - - Before test: - 01: rm -f new_file - - STDIN: - 01: ./write_on_stdout TOKEN201703241734 >new_file - - STDOUT: - SUCCESS expected_to_not match_regex `TOKEN201703241734` - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - - MISC: - SUCCESS expected_to create_file `new_file` matching_regex `TOKEN201703241734` - FAILURE expected_to create_file `new_file` with_nb_of_lines `1` - ----------------------------------------------------------------- - -21sh/redirections/outputs/truncating/002-truncates-file-if-exists (FAILED) - - Description: - The right redirection `>` opens the file with the oflag `O_TRUNC` so that the file size is truncated to 0 before writing in it. - - Before test: - 01: ./write_on_stdout TOKEN201703241734_first >truncated_file - - STDIN: - 01: ./write_on_stdout TOKEN201703241734_second >truncated_file - - STDOUT: - SUCCESS expected_to_not match_regex TOKEN201703241734_second - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - - MISC: - SUCCESS expected_to create_file `truncated_file` matching_regex `TOKEN201703241734_second` - SUCCESS expected_to create_file `truncated_file` not_matching_regex `TOKEN201703241734_first` - FAILURE expected_to create_file `truncated_file` with_nb_of_lines `1` - ----------------------------------------------------------------- - -21sh/redirections/outputs/truncating/003-whitespace-before-filename (FAILED) - - Description: - The file name for a right redirection can be specified closely to the character `>` or in a separated field. - - Before test: - 01: rm -f "new_file" - - STDIN: - 01: ./write_on_stdout TOKEN201703241734 > new_file - - STDOUT: - SUCCESS expected_to_not match_regex `TOKEN201703241734` - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - - MISC: - SUCCESS expected_to create_file `new_file` matching_regex `TOKEN201703241734` - FAILURE expected_to create_file `new_file` with_nb_of_lines `1` - ----------------------------------------------------------------- - -21sh/redirections/outputs/truncating/multiple/004-together (FAILED) - - Description: - A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`. - - Before test: - 01: rm -f "new_file_stderr_and_stdout" - - STDIN: - 01: ./write_on_stdout_and_stderr TOKEN201703241734_1 TOKEN201703241734_2 &>new_file_stderr_and_stdout - - STDOUT: - FAILURE expected_to_not match_regex `TOKEN201703241734_1` - SUCCESS expected_to_not match_regex `TOKEN201703241734_2` - 01: TOKEN201703241734_1 - - STDERR: - SUCCESS expected_to_not match_regex `TOKEN201703241734_1` - FAILURE expected_to_not match_regex `TOKEN201703241734_2` - 01: TOKEN201703241734_2 - - MISC: - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703241734_1$` - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703241734_2$` - ----------------------------------------------------------------- - -21sh/redirections/outputs/truncating/multiple/005-together-with-whitespaces (FAILED) - - Description: - A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`. - In this test, we specify the file name in a separate field. - - Before test: - 01: rm -f new_file_stderr_and_stdout - - STDIN: - 01: ./write_on_stdout_and_stderr TOKEN201703241734_1 TOKEN201703241734_2 &> new_file_stderr_and_stdout - - STDOUT: - FAILURE expected_to_not match_regex `TOKEN201703241734_1` - SUCCESS expected_to_not match_regex `TOKEN201703241734_2` - 01: TOKEN201703241734_1 - - STDERR: - SUCCESS expected_to_not match_regex `TOKEN201703241734_1` - FAILURE expected_to_not match_regex `TOKEN201703241734_2` - 01: TOKEN201703241734_2 - - MISC: - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703241734_1$` - FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703241734_2$` - ----------------------------------------------------------------- - -21sh/redirections/outputs/truncating/stderr/001-works (FAILED) - - Description: - The purpose of this test is to check that redirecting the standard error STDERR to a file `2>` works. In this test, the binary writes a token on each standard and error output, so that only the STDOUT is outputted and STDERR is written in a file `new_file_stderr`. - - Before test: - 01: rm -f "./new_file_stderr" - - STDIN: - 01: ./write_on_stdout_and_stderr TOKEN201703241734_STDOUT TOKEN201703241734_STDERR 2>new_file_stderr - - STDOUT: - SUCCESS expected_to match_regex `TOKEN201703241734_STDOUT` - 01: TOKEN201703241734_STDOUT - - STDERR: - SUCCESS expected_to_not match_regex `TOKEN201703241734_STDERR` - (no output) - - MISC: - SUCCESS expected_to create_file `new_file_stderr` matching_regex `TOKEN201703241734_STDERR` - FAILURE expected_to create_file `new_file_stderr` with_nb_of_lines 1 - ----------------------------------------------------------------- - -21sh/redirections/outputs/truncating/stdout/001-with-explicit-fd (FAILED) - - Description: - The purpose of this test is to check if '1>' redirect STDIN to a file. - We are using echo with one argument. The output should NOT return anything on the standard output. - - Before test: - 01: rm -f new_file - - STDIN: - 01: /bin/echo TOKEN1 1>new_file - - STDOUT: - SUCCESS expected_to_not match_regex TOKEN1 - (no output) - - STDERR: - (no output) - - MISC: - SUCCESS expected_to create_file new_file matching_regex TOKEN1 - FAILURE expected_to create_file new_file with_nb_of_lines 1 - ----------------------------------------------------------------- - -21sh/separators/semicolon/003-parse-error-empty-inline-command (FAILED) - - Description: - The purpose of this test is to check that using the simicolon separator `;` with empty commands results in error. - - STDIN: - 01: ./write_on_stdout TOKEN201703241734 ; ; ./exit_with_status 42 - - STDOUT: - SUCCESS expected_to be_empty - (no output) - - STDERR: - SUCCESS expected_to_not be_empty - SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error` - 01: syntax error near unexpected token `;' - - MISC: - SUCCESS expected_to_not exit_with_status `42` - FAILURE expected_to_not exit_with_status `0` - -Total tests: 36 -Total failed tests: 9 -Total pending tests: 0 diff --git a/42sh/42ShellTester/file b/42sh/42ShellTester/file new file mode 100644 index 00000000..13370648 --- /dev/null +++ b/42sh/42ShellTester/file @@ -0,0 +1,10 @@ +42ShellTester.sh +README.md +file +lib +log +minishell_error +spec +support +tasks +tmp diff --git a/42sh/42ShellTester/log b/42sh/42ShellTester/log index 89d7badb..975234a4 100644 --- a/42sh/42ShellTester/log +++ b/42sh/42ShellTester/log @@ -1,116 +1,25 @@ -...x...~......xx....~...~.....~.....~.....~........... +.x........................xxxx....x. ---------------------------------------------------------------- -minishell/binary/004-binary-test-empty-path (FAILED) +21sh/misc/002-simple-command-line (FAILED) Description: - The purpose of this test is to check that the Shell finds binaries that are located in the current directory when the environment variable PATH is empty. + The purpose of this test is to check that the Shell is able to execute a simple command line that contains separators `;`, pipes `|`, and a right redirection `>`. Before test: - 01: export PATH="" + 01: rm -rf "./size" + 02: rm -rf "TOKEN201703270303" + 03: echo '^'$(echo TOKEN201703270303_FILE_TOKEN201703270303_STDOUT | wc -c)'$' > "./size" STDIN: - 01: write_on_stdout "TOKEN201703252056" + 01: mkdir TOKEN201703270303 ; cd TOKEN201703270303 ; touch TOKEN201703270303_FILE ; ls -1 ; ls | cat | wc -c > TOKEN201703270303_STDOUT ; cat TOKEN201703270303_STDOUT STDOUT: - FAILURE expected_to match_regex `TOKEN201703252056` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ../../42sh: command not found: write_on_stdout - - MISC: - FAILURE expected_to exit_with_status `0` - ----------------------------------------------------------------- - -minishell/binary/008-binary-too-many-symbolic-links-encountered (WARNING) - - Description: - The purpose of this test is to check that trying to execute a path that encounters an infinite loop of symbolic link results in an error on standard error and a failure exit status. - - Before test: - 01: rm -rf ./symbolic_link1 ./symbolic_link2 ./symbolic_link3 - 02: ln -s ./symbolic_link1 ./symbolic_link2 - 03: ln -s ./symbolic_link2 ./symbolic_link3 - 04: ln -s ./symbolic_link3 ./symbolic_link1 - - STDIN: - 01: ./symbolic_link1 - - STDOUT: - SUCCESS might be_empty - (no output) - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `[Tt]oo many.*symbolic links` - 01: ../../42sh: ./symbolic_link1: no such file or directory - - MISC: - SUCCESS expected_to_not exit_with_status 0 - ----------------------------------------------------------------- - -minishell/builtins/cd/007-symbolic-link (FAILED) - - Description: - The purpose of this test is to check that using a symbolic link as first argument with the builtin `cd` results in moving the linked directory. - - Before test: - 01: rm -f "./symbolic_link" - 02: mkdir -p "./sub_directory" - 03: ln -s "./sub_directory" "./symbolic_link" - - STDIN: - 01: cd symbolic_link - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - 03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_env - - STDOUT: - SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD$` - FAILURE expected_to match_regex `^PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/symbolic_link$` - 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD - 02: ------------------------------ - 03: TERM_PROGRAM=iTerm.app - 04: TERM=screen-256color - 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.h7gvN9K1go/Render - 09: TERM_PROGRAM_VERSION=3.0.10 - 10: TERM_SESSION_ID=w0t0p1:D7FAE8F0-DDCC-428E-AC84-622B27EDC123 - 11: ZSH=/Users/ariard/.oh-my-zsh - 12: USER=ariard - 13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.1T0c86pYlP/Listeners - 14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 15: PAGER=less - 16: TMUX=/private/tmp/tmux-18965/default,23758,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 - 20: MAIL=ariard@student.42.fr - 21: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory - 22: LANG=en_US.UTF-8 - 23: ITERM_PROFILE=Default - 24: XPC_FLAGS=0x0 - 25: TMUX_PANE=%21 - 26: XPC_SERVICE_NAME=0 - 27: SHLVL=4 - 28: HOME=/Users/ariard - 29: COLORFGBG=7;0 - 30: ITERM_SESSION_ID=w0t0p1:D7FAE8F0-DDCC-428E-AC84-622B27EDC123 - 31: LOGNAME=ariard - 32: LESS=-R - 33: LC_CTYPE=en_US.UTF-8 - 34: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 35: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 36: _=../../42sh - 37: ?=0 - 38: ------------------------------ - 39: TOTAL ENVIRONMENT VARIABLES: 35 + SUCCESS expected_to match_regex `TOKEN201703270303_FILE$` + FAILURE expected_to match_each_regex_of_file `./size` + 01: TOKEN201703270303_FILE + 02: 23 STDERR:  SUCCESS expected_to be_empty @@ -118,229 +27,138 @@ ---------------------------------------------------------------- -minishell/builtins/cd/008-symbolic-link-2 (FAILED) +21sh/redirections/outputs/truncating/multiple/002-together-stdout-first (FAILED) Description: - The purpose of this test is to check that using a symbolic link as first argument with the builtin `cd` results in moving to the linked directory. In this test, the directory is linked with to chained symbolic links. + A right redirection can be associated to the twice outputs by using `M>&N`, that means `redirect M to where N is redirected`. + In this test the standard output is specified first. Before test: - 01: rm -f "./symbolic_link1" "./symbolic_link2" - 02: mkdir -p "./sub_directory" - 03: ln -s "./sub_directory" "./symbolic_link1" - 04: ln -s "./symbolic_link1" "./symbolic_link2" + 01: rm -f new_file_stderr_and_stdout STDIN: - 01: cd symbolic_link2 - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - 03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_env + 01: ./write_on_stdout_and_stderr TOKEN201703270303_1 TOKEN201703270303_2 1>new_file_stderr_and_stdout 2>&1 STDOUT: - SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD$` - FAILURE expected_to match_regex `^PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/symbolic_link2$` - 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD - 02: ------------------------------ - 03: TERM_PROGRAM=iTerm.app - 04: TERM=screen-256color - 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.h7gvN9K1go/Render - 09: TERM_PROGRAM_VERSION=3.0.10 - 10: TERM_SESSION_ID=w0t0p1:D7FAE8F0-DDCC-428E-AC84-622B27EDC123 - 11: ZSH=/Users/ariard/.oh-my-zsh - 12: USER=ariard - 13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.1T0c86pYlP/Listeners - 14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 15: PAGER=less - 16: TMUX=/private/tmp/tmux-18965/default,23758,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 - 20: MAIL=ariard@student.42.fr - 21: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory - 22: LANG=en_US.UTF-8 - 23: ITERM_PROFILE=Default - 24: XPC_FLAGS=0x0 - 25: TMUX_PANE=%21 - 26: XPC_SERVICE_NAME=0 - 27: SHLVL=4 - 28: HOME=/Users/ariard - 29: COLORFGBG=7;0 - 30: ITERM_SESSION_ID=w0t0p1:D7FAE8F0-DDCC-428E-AC84-622B27EDC123 - 31: LOGNAME=ariard - 32: LESS=-R - 33: LC_CTYPE=en_US.UTF-8 - 34: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 35: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 36: _=../../42sh - 37: ?=0 - 38: ------------------------------ - 39: TOTAL ENVIRONMENT VARIABLES: 35 + SUCCESS expected_to_not match_regex `TOKEN201703270303_1` + SUCCESS expected_to_not match_regex `TOKEN201703270303_2` + (no output) STDERR: + SUCCESS expected_to_not match_regex `TOKEN201703270303_1` + SUCCESS expected_to_not match_regex `TOKEN201703270303_2` + (no output) + + MISC: + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703270303_1$` + SUCCESS expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703270303_2$` + +---------------------------------------------------------------- + +21sh/redirections/outputs/truncating/multiple/003-together-stderr-first (FAILED) + + Description: + A right redirection can be associated to the twice outputs by using `M>&N`, that means `redirect M to where N is redirected`. + In this test the standard error is specified first. + + Before test: + 01: rm -f new_file_stderr_and_stdout + + STDIN: + 01: ./write_on_stdout_and_stderr TOKEN201703270303_1 TOKEN201703270303_2 2>new_file_stderr_and_stdout 1>&2 + + STDOUT: + SUCCESS expected_to_not match_regex `TOKEN201703270303_1` + SUCCESS expected_to_not match_regex `TOKEN201703270303_2` + (no output) + + STDERR: + SUCCESS expected_to_not match_regex `TOKEN201703270303_1` + SUCCESS expected_to_not match_regex `TOKEN201703270303_2` + (no output) + + MISC: + SUCCESS expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703270303_1$` + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703270303_2$` + +---------------------------------------------------------------- + +21sh/redirections/outputs/truncating/multiple/004-together (FAILED) + + Description: + A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`. + + Before test: + 01: rm -f "new_file_stderr_and_stdout" + + STDIN: + 01: ./write_on_stdout_and_stderr TOKEN201703270303_1 TOKEN201703270303_2 &>new_file_stderr_and_stdout + + STDOUT: + FAILURE expected_to_not match_regex `TOKEN201703270303_1` + SUCCESS expected_to_not match_regex `TOKEN201703270303_2` + 01: TOKEN201703270303_1 + + STDERR: + SUCCESS expected_to_not match_regex `TOKEN201703270303_1` + FAILURE expected_to_not match_regex `TOKEN201703270303_2` + 01: TOKEN201703270303_2 + + MISC: + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703270303_1$` + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703270303_2$` + +---------------------------------------------------------------- + +21sh/redirections/outputs/truncating/multiple/005-together-with-whitespaces (FAILED) + + Description: + A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`. + In this test, we specify the file name in a separate field. + + Before test: + 01: rm -f new_file_stderr_and_stdout + + STDIN: + 01: ./write_on_stdout_and_stderr TOKEN201703270303_1 TOKEN201703270303_2 &> new_file_stderr_and_stdout + + STDOUT: + FAILURE expected_to_not match_regex `TOKEN201703270303_1` + SUCCESS expected_to_not match_regex `TOKEN201703270303_2` + 01: TOKEN201703270303_1 + + STDERR: + SUCCESS expected_to_not match_regex `TOKEN201703270303_1` + FAILURE expected_to_not match_regex `TOKEN201703270303_2` + 01: TOKEN201703270303_2 + + MISC: + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703270303_1$` + FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703270303_2$` + +---------------------------------------------------------------- + +21sh/separators/semicolon/003-parse-error-empty-inline-command (FAILED) + + Description: + The purpose of this test is to check that using the simicolon separator `;` with empty commands results in error. + + STDIN: + 01: ./write_on_stdout TOKEN201703270303 ; ; ./exit_with_status 42 + + STDOUT:  SUCCESS expected_to be_empty  (no output) ----------------------------------------------------------------- - -minishell/builtins/cd/errors/001-not-a-directory (WARNING) - - Description: - The purpose of this test is to check that using a file name as first argument with the builtin `cd` results in error and not changing current directory. - - Before test: - 01: touch "./not_a_directory" - - STDIN: - 01: cd not_a_directory - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - - STDOUT: - SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD` - 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD - STDERR:  SUCCESS expected_to_not be_empty - WARNING might match_regex `[Nn]ot a directory` - 01: ../../42sh: cd : ./not_a_directory: Permission denied - ----------------------------------------------------------------- - -minishell/builtins/cd/errors/005-too-many-symbolic-links-encountered (WARNING) - - Description: - The purpose of this test is to check that using a symbolic link resulting in ELOOP error as first argument with the builtin `cd` results in error and not changing current directory. - - Before test: - 01: rm -f "./symbolic_link1" "./symbolic_link2" "./symbolic_link3" - 02: ln -s "./symbolic_link1" "./symbolic_link2" - 03: ln -s "./symbolic_link2" "./symbolic_link3" - 04: ln -s "./symbolic_link3" "./symbolic_link1" - - STDIN: - 01: cd symbolic_link1 - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - - STDOUT: - SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD` - 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `[Tt]oo many.*symbolic links` - 01: ../../42sh: cd : ./symbolic_link1: No such file or directory - ----------------------------------------------------------------- - -minishell/builtins/cd/options/001-not-following-links (WARNING) - - Description: - The purpose of this test is to check that using symbolic links twice with the builtin `cd` and the option `-P` results in a correct environment variable PWD. The option `-P` makes the Shell to resolve symbolic links. - - Before test: - 01: rm -fr "./sub_directory_link" "./sub_directory" - 02: mkdir -p "./sub_directory/sub_sub_directory" - 03: ln -s "./sub_directory" "./sub_directory_link" - 04: ln -s "./sub_sub_directory" "./sub_directory/sub_sub_directory_link" - - STDIN: - 01: cd -P sub_directory_link - 02: cd -P sub_sub_directory_link - 03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_env - - STDOUT: - SUCCESS expected_to match_regex `PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory/sub_sub_directory` - 01: ------------------------------ - 02: TERM_PROGRAM=iTerm.app - 03: TERM=screen-256color - 04: SHELL=/bin/zsh - 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.h7gvN9K1go/Render - 08: TERM_PROGRAM_VERSION=3.0.10 - 09: TERM_SESSION_ID=w0t0p1:D7FAE8F0-DDCC-428E-AC84-622B27EDC123 - 10: ZSH=/Users/ariard/.oh-my-zsh - 11: USER=ariard - 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.1T0c86pYlP/Listeners - 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 14: PAGER=less - 15: TMUX=/private/tmp/tmux-18965/default,23758,2 - 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 17: LSCOLORS=Gxfxcxdxbxegedabagacad - 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 19: MAIL=ariard@student.42.fr - 20: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory/sub_sub_directory - 21: LANG=en_US.UTF-8 - 22: ITERM_PROFILE=Default - 23: XPC_FLAGS=0x0 - 24: TMUX_PANE=%21 - 25: XPC_SERVICE_NAME=0 - 26: SHLVL=4 - 27: HOME=/Users/ariard - 28: COLORFGBG=7;0 - 29: ITERM_SESSION_ID=w0t0p1:D7FAE8F0-DDCC-428E-AC84-622B27EDC123 - 30: LOGNAME=ariard - 31: LESS=-R - 32: LC_CTYPE=en_US.UTF-8 - 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 34: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 35: _=../../42sh - 36: ?=73 - 37: ------------------------------ - 38: TOTAL ENVIRONMENT VARIABLES: 35 - - STDERR: - WARNING might be_empty - 01: ../../42sh: cd : ./sub_directory_link: Symlink not resolved - 02: ../../42sh: cd : ./sub_sub_directory_link: Symlink not resolved - ----------------------------------------------------------------- - -minishell/builtins/env/errors/001-command-not-found (WARNING) - - Description: - The purpose of this test is to check that using the builtin `env` with an invalid binary as argument results in an error and failure exit status. - - Before test: - 01: rm -f "./invalid_binary" - - STDIN: - 01: env ./invalid_binary - - STDOUT: - (no output) - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `[Cc]ommand not found` - 01: ../../42sh: env: ./invalid_binary: No such file or directory + SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error` + 01: syntax error near unexpected token `;' MISC: - SUCCESS expected_to_not exit_with_status `0` + SUCCESS expected_to_not exit_with_status `42` + FAILURE expected_to_not exit_with_status `0` ----------------------------------------------------------------- - -minishell/builtins/exit/errors/001-too-many-args (WARNING) - - Description: - The purpose of this test is to check that using a wrong number of arguments with the builtin `exit` does not result in the Shell termination but an error on standard error. - - STDIN: - 01: exit 21 42 - 02: ./write_on_stdout TOKEN201703252056 - - STDOUT: - SUCCESS expected_to match_regex `TOKEN201703252056` - 01: TOKEN201703252056 - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `([Tt]oo many arguments|[Aa]rgument list too long)` - 01: ../../42sh: exit: too many argument required - - MISC: - SUCCESS expected_to exit_with_status `0` - -Total tests: 54 -Total failed tests: 3 +Total tests: 36 +Total failed tests: 6 Total pending tests: 0 diff --git a/42sh/42sh_error b/42sh/42sh_error deleted file mode 100644 index 6455094c..00000000 --- a/42sh/42sh_error +++ /dev/null @@ -1,2501 +0,0 @@ -x.xxx..x.xxx.xx.xxx......xxxxx...xxxxxxxxxx.......xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxx.xx.xxx.x......xxxx.xxxxxx...xxxx...........xxxxxx.................xx...... - ----------------------------------------------------------------- - -42sh/builtins/export/001-display-env (FAILED) - - Description: - The purpose of this test is to check that using the builtin `export` without parameters results at least in a display of the environment variables. - - Before test: - 01: rm -rf "./stored_env" - 02: env | awk 'BEGIN {FS="="} $0 !~ /^(OLDPWD|_)/ {print $1"="}' > "./stored_env" - - STDIN: - 01: export - - STDOUT: - FAILURE expected_to match_each_regex_of_file `./stored_env` - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/builtins/export/003-export-basic-key-value-2 (FAILED) - - Description: - The purpose of this test is to check that the builtin `export` may declare a new environment variable and is able to display it later. - - Before test: - 01: unset "TOKEN201703241737_NAME" - - STDIN: - 01: export TOKEN201703241737_NAME=TOKEN201703241737_VALUE - 02: export - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703241737_NAME=["]?TOKEN201703241737_VALUE["]?$` - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/builtins/export/004-export-empty-variable-1 (FAILED) - - Description: - The purpose of this test is to check that exporting an empty variable does not add it to the environment. - - Before test: - 01: unset "TOKEN201703241737" - - STDIN: - 01: export TOKEN201703241737 - 02: ./display_env - - STDOUT: - FAILURE expected_to_not match_regex `TOKEN201703241737` - 01: ------------------------------ - 02: TERM_PROGRAM=iTerm.app - 03: TERM=screen-256color - 04: SHELL=/bin/zsh - 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render - 08: TERM_PROGRAM_VERSION=3.0.10 - 09: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 10: ZSH=/Users/ariard/.oh-my-zsh - 11: USER=ariard - 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 14: PAGER=less - 15: TMUX=/private/tmp/tmux-18965/default,73780,2 - 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 17: LSCOLORS=Gxfxcxdxbxegedabagacad - 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 19: MAIL=ariard@student.42.fr - 20: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 21: LANG=en_US.UTF-8 - 22: ITERM_PROFILE=Default - 23: XPC_FLAGS=0x0 - 24: TMUX_PANE=%9 - 25: XPC_SERVICE_NAME=0 - 26: SHLVL=4 - 27: HOME=/Users/ariard - 28: COLORFGBG=7;0 - 29: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 30: LOGNAME=ariard - 31: LESS=-R - 32: LC_CTYPE=en_US.UTF-8 - 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 34: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 35: _=../../42sh - 36: ?=0 - 37: TOKEN201703241737= - 38: ------------------------------ - 39: TOTAL ENVIRONMENT VARIABLES: 36 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/builtins/export/005-export-empty-variable-2 (FAILED) - - Description: - The purpose of this test is to check that exporting an empty variable does not add it to the environment, but can be displayed with the builtin `export`. - - Before test: - 01: unset "TOKEN201703241737" - - STDIN: - 01: export TOKEN201703241737 - 02: export - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703241737` - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/builtins/export/008-local-to-environment (FAILED) - - Description: - The purpose of this test is to check that a declared local variable may be exported to the environment with the builtin `export`. - - STDIN: - 01: TOKEN201703241737_NAME=TOKEN201703241737_VALUE - 02: export TOKEN201703241737_NAME - 03: ./display_env - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737_NAME=TOKEN201703241737_VALUE$` - 01: ------------------------------ - 02: TERM_PROGRAM=iTerm.app - 03: TERM=screen-256color - 04: SHELL=/bin/zsh - 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render - 08: TERM_PROGRAM_VERSION=3.0.10 - 09: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 10: ZSH=/Users/ariard/.oh-my-zsh - 11: USER=ariard - 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 14: PAGER=less - 15: TMUX=/private/tmp/tmux-18965/default,73780,2 - 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 17: LSCOLORS=Gxfxcxdxbxegedabagacad - 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 19: MAIL=ariard@student.42.fr - 20: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 21: LANG=en_US.UTF-8 - 22: ITERM_PROFILE=Default - 23: XPC_FLAGS=0x0 - 24: TMUX_PANE=%9 - 25: XPC_SERVICE_NAME=0 - 26: SHLVL=4 - 27: HOME=/Users/ariard - 28: COLORFGBG=7;0 - 29: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 30: LOGNAME=ariard - 31: LESS=-R - 32: LC_CTYPE=en_US.UTF-8 - 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 34: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 35: _=../../42sh - 36: ?=0 - 37: TOKEN201703241737_NAME=OKEN201703241737_VALUE - 38: ------------------------------ - 39: TOTAL ENVIRONMENT VARIABLES: 36 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/builtins/export/010-export-with-equal-but-no-value-part2 (FAILED) - - Description: - The purpose of this test is to check if the builtin export works fine with equal sign but no value. This test is based on the local variables return. - - Before test: - 01: unset "TOKEN201703241737" - - STDIN: - 01: export TOKEN201703241737_NAME= - 02: export - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703241737_NAME=` - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/builtins/export/errors/001-invalid-identifier-1 (FAILED) - - Description: - The purpose of this test is to check that trying to export an invalid variable identifier results in error. - - STDIN: - 01: export 42=TOKEN201703241737 - - STDOUT: - SUCCESS expected_to_not match_regex `TOKEN201703241737` - (no output) - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `(not.*identifier|must begin.*letter)` - 01: ../../42sh: export: 42: invalid variable name - - MISC: - FAILURE expected_to_not exit_with_status `0` - ----------------------------------------------------------------- - -42sh/builtins/export/errors/002-invalid-identifier-2 (FAILED) - - Description: - The purpose of this test is to check that trying to export an invalid variable identifier results in error. - - STDIN: - 01: export .=TOKEN201703241737 - - STDOUT: - SUCCESS expected_to_not match_regex `TOKEN201703241737` - (no output) - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `(not.*identifier|must begin.*letter)` - 01: ../../42sh: export: .: invalid variable name - - MISC: - FAILURE expected_to_not exit_with_status `0` - ----------------------------------------------------------------- - -42sh/builtins/export/mixed/001-export-and-tmp-env-part1 (FAILED) - - Description: - The purpose of this test is to check that modifying the environment for the builtin `export` results in an added variable into the exported list. - - Before test: - 01: unset "TOKEN201703241737_NAME" - - STDIN: - 01: TOKEN201703241737_NAME=TOKEN201703241737_VALUE export TOKEN201703241737_NAME - 02: export - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703241737_NAME=["]?TOKEN201703241737_VALUE["]?` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ../../42sh: command not found: TOKEN201703241737_NAME=TOKEN201703241737_VALUE - ----------------------------------------------------------------- - -42sh/builtins/export/mixed/002-export-and-tmp-env-part2 (FAILED) - - Description: - The purpose of this test is to check that modifying the environment for the builtin `export` results in an added environment variable. - - Before test: - 01: unset "TOKEN201703241737_NAME" - - STDIN: - 01: TOKEN201703241737_NAME=TOKEN201703241737_VALUE export TOKEN201703241737_NAME - 02: ./display_env - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703241737_NAME=TOKEN201703241737_VALUE` - 01: ------------------------------ - 02: TERM_PROGRAM=iTerm.app - 03: TERM=screen-256color - 04: SHELL=/bin/zsh - 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render - 08: TERM_PROGRAM_VERSION=3.0.10 - 09: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 10: ZSH=/Users/ariard/.oh-my-zsh - 11: USER=ariard - 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 14: PAGER=less - 15: TMUX=/private/tmp/tmux-18965/default,73780,2 - 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 17: LSCOLORS=Gxfxcxdxbxegedabagacad - 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 19: MAIL=ariard@student.42.fr - 20: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 21: LANG=en_US.UTF-8 - 22: ITERM_PROFILE=Default - 23: XPC_FLAGS=0x0 - 24: TMUX_PANE=%9 - 25: XPC_SERVICE_NAME=0 - 26: SHLVL=4 - 27: HOME=/Users/ariard - 28: COLORFGBG=7;0 - 29: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 30: LOGNAME=ariard - 31: LESS=-R - 32: LC_CTYPE=en_US.UTF-8 - 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 34: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 35: _=../../42sh - 36: ?=127 - 37: ------------------------------ - 38: TOTAL ENVIRONMENT VARIABLES: 35 - - STDERR: - FAILURE expected_to be_empty - 01: ../../42sh: command not found: TOKEN201703241737_NAME=TOKEN201703241737_VALUE - ----------------------------------------------------------------- - -42sh/builtins/export/options/002-export-p-param-and-token-should-add-local-var-only-part1 (FAILED) - - Description: - The purpose of this test is to check if export with -p option + token , add the variable into export list but not in env list. And don't display the export variable on stdout. - - Before test: - 01: rm -f "./stored_env" - 02: unset "TOKEN201703241737_NAME" - 03: export | awk 'BEGIN {FS="="} $0 !~ /^(OLDPWD|_)/ {print $1"="}' > "./stored_env" - - STDIN: - 01: export -p TOKEN201703241737_NAME - 02: export - - STDOUT: - FAILURE expected_to_not match_each_regex_of_file `./stored_env` - FAILURE expected_to match_regex `TOKEN201703241737_NAME` - 01: export TERM_PROGRAM=iTerm.app - 02: export TERM=screen-256color - 03: export SHELL=/bin/zsh - 04: export HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 05: export TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 06: export Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render - 07: export TERM_PROGRAM_VERSION=3.0.10 - 08: export TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 09: export ZSH=/Users/ariard/.oh-my-zsh - 10: export USER=ariard - 11: export SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 12: export __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 13: export PAGER=less - 14: export TMUX=/private/tmp/tmux-18965/default,73780,2 - 15: export HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 16: export LSCOLORS=Gxfxcxdxbxegedabagacad - 17: export PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 18: export MAIL=ariard@student.42.fr - 19: export PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 20: export LANG=en_US.UTF-8 - 21: export ITERM_PROFILE=Default - 22: export XPC_FLAGS=0x0 - 23: export TMUX_PANE=%9 - 24: export XPC_SERVICE_NAME=0 - 25: export SHLVL=4 - 26: export HOME=/Users/ariard - 27: export COLORFGBG=7;0 - 28: export ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 29: export LOGNAME=ariard - 30: export LESS=-R - 31: export LC_CTYPE=en_US.UTF-8 - 32: export TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 33: export OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 34: export _=../../42sh - 35: export ?=0 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/builtins/export/options/003-export-p-param-and-token-should-add-local-var-only-part2 (FAILED) - - Description: - The purpose of this test is to check that the builtin `export` with option `-p` results in an added variable into the export list but not from the environment. - - Before test: - 01: rm -f "./stored_env" - 02: unset "TOKEN201703241737_NAME" - 03: export | awk 'BEGIN {FS="="} $0 !~ /^(OLDPWD|_)/ {print $1"="}' > "./stored_env" - - STDIN: - 01: export -p TOKEN201703241737_NAME - 02: ./display_env - - STDOUT: - FAILURE expected_to_not match_each_regex_of_file `./stored_env` - SUCCESS expected_to_not match_regex `TOKEN201703241737_NAME` - 01: export TERM_PROGRAM=iTerm.app - 02: export TERM=screen-256color - 03: export SHELL=/bin/zsh - 04: export HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 05: export TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 06: export Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render - 07: export TERM_PROGRAM_VERSION=3.0.10 - 08: export TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 09: export ZSH=/Users/ariard/.oh-my-zsh - 10: export USER=ariard - 11: export SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 12: export __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 13: export PAGER=less - 14: export TMUX=/private/tmp/tmux-18965/default,73780,2 - 15: export HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 16: export LSCOLORS=Gxfxcxdxbxegedabagacad - 17: export PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 18: export MAIL=ariard@student.42.fr - 19: export PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 20: export LANG=en_US.UTF-8 - 21: export ITERM_PROFILE=Default - 22: export XPC_FLAGS=0x0 - 23: export TMUX_PANE=%9 - 24: export XPC_SERVICE_NAME=0 - 25: export SHLVL=4 - 26: export HOME=/Users/ariard - 27: export COLORFGBG=7;0 - 28: export ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 29: export LOGNAME=ariard - 30: export LESS=-R - 31: export LC_CTYPE=en_US.UTF-8 - 32: export TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 33: export OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 34: export _=../../42sh - 35: export ?=0 - 36: ------------------------------ - 37: TERM_PROGRAM=iTerm.app - 38: TERM=screen-256color - 39: SHELL=/bin/zsh - 40: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 41: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 42: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render - 43: TERM_PROGRAM_VERSION=3.0.10 - 44: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 45: ZSH=/Users/ariard/.oh-my-zsh - 46: USER=ariard - 47: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 48: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 49: PAGER=less - 50: TMUX=/private/tmp/tmux-18965/default,73780,2 - 51: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 52: LSCOLORS=Gxfxcxdxbxegedabagacad - 53: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 54: MAIL=ariard@student.42.fr - 55: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 56: LANG=en_US.UTF-8 - 57: ITERM_PROFILE=Default - 58: XPC_FLAGS=0x0 - 59: TMUX_PANE=%9 - 60: XPC_SERVICE_NAME=0 - 61: SHLVL=4 - 62: HOME=/Users/ariard - 63: COLORFGBG=7;0 - 64: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 65: LOGNAME=ariard - 66: LESS=-R - 67: LC_CTYPE=en_US.UTF-8 - 68: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 69: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 70: _=../../42sh - 71: ?=0 - 72: ------------------------------ - 73: TOTAL ENVIRONMENT VARIABLES: 35 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/builtins/export/options/004-export-n-param (FAILED) - - Description: - The purpose of this test is to check that using the builtin `export` with option `-n` results in a removed environment variable. - - Before test: - 01: export TOKEN201703241737_NAME=TOKEN201703241737_VALUE - - STDIN: - 01: export -n TOKEN201703241737_NAME - 02: export - 03: ./display_env - - STDOUT: - SUCCESS expected_to_not match_regex `TOKEN201703241737_NAME` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: export: invalid option -n - 02: ./lib/main.sh: line 102: 12935 Segmentation fault: 11 ../../42sh - ----------------------------------------------------------------- - -42sh/escaping/mixed/globbing/brace-expansion/002-it-expands-braces-1 (FAILED) - - Description: - The purpose of this test is to check that using multiple escape characters `\\` results in a good behavior with the brace expansion. - - STDIN: - 01: ./write_all_arguments_on_stdout \\{1..2} - - STDOUT: - FAILURE expected_to match_regex `^\1@\2@$` - 01: \{1..2}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/escaping/mixed/globbing/brace-expansion/003-it-expands-braces-2 (FAILED) - - Description: - The purpose of this test is to check that using multiple escape characters `\\` results in a good behavior with the brace expansion. - - STDIN: - 01: ./write_all_arguments_on_stdout \\\{1..2} \\\\{1..2} \\\\\{1..2} \\\\\\{1..2} - - STDOUT: - FAILURE expected_to match_regex `^\[{]1..2}@\\1@\\2@\\[{]1..2}@\\\1@\\\2@$` - 01: \{1..2}@\\{1..2}@\\{1..2}@\\\{1..2}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/escaping/mixed/globbing/bracket-expansion/001-it-does-not-expand-brackets (FAILED) - - Description: - The purpose of this test is to check that escaping brackets does not result in an expansion process. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'b' 'c' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout \[abc] [abc\] \[abc\] - - STDOUT: - FAILURE expected_to match_regex `^[[]abc]@[[]abc]@[[]abc]@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/escaping/mixed/globbing/bracket-expansion/002-escaped-inversion-mark (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with an inversion mark `!` or `^` as pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'b' 'c' 'd' 'e' 'f' '!' '^' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [\!abc] - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [\^abc] - - STDOUT: - FAILURE expected_to match_regex `!@` - FAILURE expected_to match_regex `[\^]@` - FAILURE expected_to match_regex `a@` - FAILURE expected_to match_regex `b@` - FAILURE expected_to match_regex `c@` - SUCCESS expected_to_not match_regex `d@` - SUCCESS expected_to_not match_regex `e@` - SUCCESS expected_to_not match_regex `f@` - WARNING might match_regex `^!@a@b@c@$` - WARNING might match_regex `^[\^]@a@b@c@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/escaping/mixed/globbing/bracket-expansion/003-it-takes-escaped-bracket-as-pattern-character (FAILED) - - Description: - The purpose of this test is to check that a closing bracket ']' may be escaped in a backet expansion pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'b' 'c' 'd' 'e' 'f' ']' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [abc\]def] - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [abc\\\]def] - 03: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [abc\\\\\]def] - 04: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [abc\\\\\\\]def] - - STDOUT: - FAILURE expected_to match_regex `a@` 4 times - FAILURE expected_to match_regex `b@` 4 times - FAILURE expected_to match_regex `c@` 4 times - FAILURE expected_to match_regex `]@` 4 times - FAILURE expected_to match_regex `d@` 4 times - FAILURE expected_to match_regex `e@` 4 times - FAILURE expected_to match_regex `f@` 4 times - SUCCESS expected_to_not match_regex `def` - WARNING might match_regex `^]@a@b@c@d@e@f@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/001-simple-ascending-1 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with an ASCII range in ascending order. - - STDIN: - 01: ./write_all_arguments_on_stdout {a..e} - - STDOUT: - FAILURE expected_to match_regex `^a@b@c@d@e@$` - 01: {a..e}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/002-simple-ascending-2 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with an ASCII range in ascending order. - - STDIN: - 01: ./write_all_arguments_on_stdout TOKEN201703241737{a..e}TOKEN201703241737 - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737aTOKEN201703241737@TOKEN201703241737bTOKEN201703241737@TOKEN201703241737cTOKEN201703241737@TOKEN201703241737dTOKEN201703241737@TOKEN201703241737eTOKEN201703241737@$` - 01: TOKEN201703241737{a..e}TOKEN201703241737@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/003-simple-ascending-3 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with an ASCII range in ascending order. - - STDIN: - 01: ./write_all_arguments_on_stdout {A..E} - - STDOUT: - FAILURE expected_to match_regex `^A@B@C@D@E@$` - 01: {A..E}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/004-simple-descending-1 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with an ASCII range in descending order. - - STDIN: - 01: ./write_all_arguments_on_stdout {E..A} - - STDOUT: - FAILURE expected_to match_regex `^E@D@C@B@A@$` - 01: {E..A}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/005-simple-descending-2 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with an ASCII range in descending order. - - STDIN: - 01: ./write_all_arguments_on_stdout TOKEN201703241737{E..A}TOKEN201703241737 - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737ETOKEN201703241737@TOKEN201703241737DTOKEN201703241737@TOKEN201703241737CTOKEN201703241737@TOKEN201703241737BTOKEN201703241737@TOKEN201703241737ATOKEN201703241737@$` - 01: TOKEN201703241737{E..A}TOKEN201703241737@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/006-simple-descending-3 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with an ASCII range in descending order. - - STDIN: - 01: ./write_all_arguments_on_stdout TOKEN201703241737{e..a} - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737e@TOKEN201703241737d@TOKEN201703241737c@TOKEN201703241737b@TOKEN201703241737a@$` - 01: TOKEN201703241737{e..a}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/007-identical-start-and-end (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a range of single ASCII value. - - STDIN: - 01: ./write_all_arguments_on_stdout {f..f} - - STDOUT: - FAILURE expected_to match_regex `^f@$` - 01: {f..f}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/008-multiple-1 (FAILED) - - Description: - The purpose of this test is to check that brace expansion may be performed with multiple brace patterns. - - STDIN: - 01: ./write_all_arguments_on_stdout {a..b}{c..d}{e..f} - - STDOUT: - FAILURE expected_to match_regex `^ace@acf@ade@adf@bce@bcf@bde@bdf@$` - 01: {a..b}{c..d}{e..f}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/009-multiple-2 (FAILED) - - Description: - The purpose of this test is to check that brace expansion may be performed with multiple brace patterns. - - STDIN: - 01: ./write_all_arguments_on_stdout TOKEN201703241737{a..b}abc{Z..X}def{s..s} - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737aabcZdefs@TOKEN201703241737aabcYdefs@TOKEN201703241737aabcXdefs@TOKEN201703241737babcZdefs@TOKEN201703241737babcYdefs@TOKEN201703241737babcXdefs@$` - 01: TOKEN201703241737{a..b}abc{Z..X}def{s..s}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/ascii-range/010-big-range (FAILED) - - Description: - The purpose of this test is to check that brace expansion may be performed with a big numeric range. - - STDIN: - 01: ./write_all_arguments_on_stdout {A..z} - - STDOUT: - FAILURE expected_to match_regex `^A@B@C@D@E@F@G@H@I@J@K@L@M@N@O@P@Q@R@S@T@U@V@W@X@Y@Z@.+@.?@.+@.+@_@.+@a@b@c@d@e@f@g@h@i@j@k@l@m@n@o@p@q@r@s@t@u@v@w@x@y@z@$` - 01: {A..z}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/001-simple-ascending-1 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. - - STDIN: - 01: ./write_all_arguments_on_stdout {1..5} - - STDOUT: - FAILURE expected_to match_regex `^1@2@3@4@5@$` - 01: {1..5}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/002-simple-ascending-2 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. - - STDIN: - 01: ./write_all_arguments_on_stdout TOKEN201703241737{1..5}TOKEN201703241737 - - STDOUT: - FAILURE expected_to match_regex `^TOKEN2017032417371TOKEN201703241737@TOKEN2017032417372TOKEN201703241737@TOKEN2017032417373TOKEN201703241737@TOKEN2017032417374TOKEN201703241737@TOKEN2017032417375TOKEN201703241737@$` - 01: TOKEN201703241737{1..5}TOKEN201703241737@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/003-simple-ascending-3 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. - - STDIN: - 01: ./write_all_arguments_on_stdout TOKEN201703241737{1..+5} - - STDOUT: - FAILURE expected_to match_regex `^TOKEN2017032417371@TOKEN2017032417372@TOKEN2017032417373@TOKEN2017032417374@TOKEN2017032417375@$` - 01: TOKEN201703241737{1..+5}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/004-simple-ascending-4 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. - - STDIN: - 01: ./write_all_arguments_on_stdout {-5..0}TOKEN201703241737 - - STDOUT: - FAILURE expected_to match_regex `^-5TOKEN201703241737@-4TOKEN201703241737@-3TOKEN201703241737@-2TOKEN201703241737@-1TOKEN201703241737@0TOKEN201703241737@$` - 01: {-5..0}TOKEN201703241737@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/005-simple-ascending-5 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in ascending order. - - STDIN: - 01: ./write_all_arguments_on_stdout {-100..-98}TOKEN201703241737 - - STDOUT: - FAILURE expected_to match_regex `^-100TOKEN201703241737@-99TOKEN201703241737@-98TOKEN201703241737@$` - 01: {-100..-98}TOKEN201703241737@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/006-simple-descending-1 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. - - STDIN: - 01: ./write_all_arguments_on_stdout {5..1} - - STDOUT: - FAILURE expected_to match_regex `^5@4@3@2@1@$` - 01: {5..1}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/007-simple-descending-2 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. - - STDIN: - 01: ./write_all_arguments_on_stdout TOKEN201703241737{5..1}TOKEN201703241737 - - STDOUT: - FAILURE expected_to match_regex `^TOKEN2017032417375TOKEN201703241737@TOKEN2017032417374TOKEN201703241737@TOKEN2017032417373TOKEN201703241737@TOKEN2017032417372TOKEN201703241737@TOKEN2017032417371TOKEN201703241737@$` - 01: TOKEN201703241737{5..1}TOKEN201703241737@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/008-simple-descending-3 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. - - STDIN: - 01: ./write_all_arguments_on_stdout TOKEN201703241737{5..+1} - - STDOUT: - FAILURE expected_to match_regex `^TOKEN2017032417375@TOKEN2017032417374@TOKEN2017032417373@TOKEN2017032417372@TOKEN2017032417371@$` - 01: TOKEN201703241737{5..+1}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/009-simple-descending-4 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. - - STDIN: - 01: ./write_all_arguments_on_stdout {0..-5}TOKEN201703241737 - - STDOUT: - FAILURE expected_to match_regex `^0TOKEN201703241737@-1TOKEN201703241737@-2TOKEN201703241737@-3TOKEN201703241737@-4TOKEN201703241737@-5TOKEN201703241737@$` - 01: {0..-5}TOKEN201703241737@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/010-simple-descending-5 (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a numeric range in descending order. - - STDIN: - 01: ./write_all_arguments_on_stdout {-98..-100}TOKEN201703241737 - - STDOUT: - FAILURE expected_to match_regex `^-98TOKEN201703241737@-99TOKEN201703241737@-100TOKEN201703241737@$` - 01: {-98..-100}TOKEN201703241737@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/011-identical-positive-start-and-end (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a range of single value. - - STDIN: - 01: ./write_all_arguments_on_stdout {42..42} - - STDOUT: - FAILURE expected_to match_regex `^42@$` - 01: {42..42}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/012-identical-negative-start-and-end (FAILED) - - Description: - The purpose of this test is to check that the brace expansion does work with a range of single value. - - STDIN: - 01: ./write_all_arguments_on_stdout {-42..-42} - - STDOUT: - FAILURE expected_to match_regex `^-42@$` - 01: {-42..-42}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/013-multiple-1 (FAILED) - - Description: - The purpose of this test is to check that brace expansion may be performed with multiple brace patterns. - - STDIN: - 01: ./write_all_arguments_on_stdout {1..2}{3..4}{5..6} - - STDOUT: - FAILURE expected_to match_regex `^135@136@145@146@235@236@245@246@$` - 01: {1..2}{3..4}{5..6}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/014-multiple-2 (FAILED) - - Description: - The purpose of this test is to check that brace expansion may be performed with multiple brace patterns. - - STDIN: - 01: ./write_all_arguments_on_stdout TOKEN201703241737{1..2}abc{-50..-53}def{0..0} - - STDOUT: - FAILURE expected_to match_regex `^TOKEN2017032417371abc-50def0@TOKEN2017032417371abc-51def0@TOKEN2017032417371abc-52def0@TOKEN2017032417371abc-53def0@TOKEN2017032417372abc-50def0@TOKEN2017032417372abc-51def0@TOKEN2017032417372abc-52def0@TOKEN2017032417372abc-53def0@$` - 01: TOKEN201703241737{1..2}abc{-50..-53}def{0..0}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/brace-expansion/numeric-range/015-big-range (FAILED) - - Description: - The purpose of this test is to check that brace expansion may be performed with a big numeric range. - - STDIN: - 01: ./write_all_arguments_on_stdout {-100..100} - - STDOUT: - FAILURE expected_to match_regex `^-100@-99@-98@-97@-96@-95@-94@-93@-92@-91@-90@-89@-88@-87@-86@-85@-84@-83@-82@-81@-80@-79@-78@-77@-76@-75@-74@-73@-72@-71@-70@-69@-68@-67@-66@-65@-64@-63@-62@-61@-60@-59@-58@-57@-56@-55@-54@-53@-52@-51@-50@-49@-48@-47@-46@-45@-44@-43@-42@-41@-40@-39@-38@-37@-36@-35@-34@-33@-32@-31@-30@-29@-28@-27@-26@-25@-24@-23@-22@-21@-20@-19@-18@-17@-16@-15@-14@-13@-12@-11@-10@-9@-8@-7@-6@-5@-4@-3@-2@-1@0@1@2@3@4@5@6@7@8@9@10@11@12@13@14@15@16@17@18@19@20@21@22@23@24@25@26@27@28@29@30@31@32@33@34@35@36@37@38@39@40@41@42@43@44@45@46@47@48@49@50@51@52@53@54@55@56@57@58@59@60@61@62@63@64@65@66@67@68@69@70@71@72@73@74@75@76@77@78@79@80@81@82@83@84@85@86@87@88@89@90@91@92@93@94@95@96@97@98@99@100@$` - 01: {-100..100}@ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/multi/001-range-and-char (FAILED) - - Description: - The purpose of this test is to check that brackets expansion works with a range and 2 characters as pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch '1' '2' '3' 'a' 'b' 'z' 'C' '-' '[a-z-2]' 'a-z-2' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [a-z-2] - - STDOUT: - FAILURE expected_to match_regex `-@` - FAILURE expected_to match_regex `2@` - FAILURE expected_to match_regex `a@` - FAILURE expected_to match_regex `b@` - FAILURE expected_to match_regex `z@` - SUCCESS expected_to_not match_regex `1@` - SUCCESS expected_to_not match_regex `3@` - SUCCESS expected_to_not match_regex `C@` - SUCCESS expected_to_not match_regex `[[]a-z-2]@` - SUCCESS expected_to_not match_regex `a-z-2@` - WARNING might match_regex `^-@2@a@b@z@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/multi/002-reverse-range-and-chars (FAILED) - - Description: - The purpose of this test is to check that brackets expansion works with 2 patterns. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a4' 'a3' 'a2' 'a42' 'a[42]' 'z4' 'z3' 'z2' 'z42' 'z[42]' '42' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [!a-y][42] - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [^a-y][42] - - STDOUT: - FAILURE expected_to match_regex `42@` - FAILURE expected_to match_regex `z4@` - FAILURE expected_to match_regex `z2@` - SUCCESS expected_to_not match_regex `z3@` - SUCCESS expected_to_not match_regex `z42@` - SUCCESS expected_to_not match_regex `z[[]42]@` - SUCCESS expected_to_not match_regex `a3@` - SUCCESS expected_to_not match_regex `a42@` - SUCCESS expected_to_not match_regex `a[[]42]@` - WARNING might match_regex `^42@z2@z4@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/multi/003-reverse-multi-hard (FAILED) - - Description: - The purpose of this test is to check how the value inside multiple brackets are parsed with bracket as pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch '][' 'a[' '1[' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [!]az][[] - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [^]az][[] - - STDOUT: - FAILURE expected_to match_regex `1[[]@` - SUCCESS expected_to_not match_regex `][[]@` - SUCCESS expected_to_not match_regex `a[[]@` - WARNING might match_regex `^1[[]@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/multi/004-simple-bracket+char+range (FAILED) - - Description: - The purpose of this test is to control if 2 patterns splited by a minus characters can be match. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a-0' 'a-1' 'a-2' 'b-0' 'b-1' 'b-2' 'Z-0' 'Z-1' 'Z-2' 'a1' 'Z9' 'D4' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [aZ]-[1-9] - - STDOUT: - FAILURE expected_to match_regex `a-1@` - FAILURE expected_to match_regex `a-2@` - FAILURE expected_to match_regex `Z-1@` - FAILURE expected_to match_regex `Z-2@` - SUCCESS expected_to_not match_regex `a-0@` - SUCCESS expected_to_not match_regex `b-0@` - SUCCESS expected_to_not match_regex `b-1@` - SUCCESS expected_to_not match_regex `b-2@` - SUCCESS expected_to_not match_regex `a1@` - SUCCESS expected_to_not match_regex `Z9@` - SUCCESS expected_to_not match_regex `D4@` - WARNING might match_regex `^Z-1@Z-2@a-1@a-2@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/not/001-simple-opposit-match (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with the inversion mark `!` or `^`. The expected behavior is the reversion of the following pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' '1' 'Z' 'd' 'e' 'f' 'def' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [!a1Z] - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [^a1Z] - - STDOUT: - FAILURE expected_to match_regex `d@` - FAILURE expected_to match_regex `e@` - FAILURE expected_to match_regex `f@` - SUCCESS expected_to_not match_regex `def@` - WARNING might match_regex `^d@e@f@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/not/002-simple-opposite-range (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with the inversion mark `!` or `^`. The expected behavior is the reversion of the following pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'b' 'c' 'z' '1' '2' '3' '42' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [!a-z] - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [^a-z] - - STDOUT: - FAILURE expected_to match_regex `1@` - FAILURE expected_to match_regex `2@` - FAILURE expected_to match_regex `3@` - SUCCESS expected_to_not match_regex `42@` - WARNING might match_regex `^1@2@3@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/range-pattern/001-alpha-range (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with the following pattern `[a-z]`. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'f' 'z' 'A' '1' '[a-z]' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [a-z] - - STDOUT: - FAILURE expected_to match_regex `a@` - FAILURE expected_to match_regex `f@` - FAILURE expected_to match_regex `z@` - SUCCESS expected_to_not match_regex `A@` - SUCCESS expected_to_not match_regex `1@` - SUCCESS expected_to_not match_regex `[[]a-z]@` - WARNING might match_regex `^a@f@z@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/range-pattern/002-numeric-range (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with the following pattern `[0-9]`. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch '4' '2' '1' '9' 'a' 'C' '[0-9]' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [0-9] - - STDOUT: - FAILURE expected_to match_regex `1@` - FAILURE expected_to match_regex `2@` - FAILURE expected_to match_regex `4@` - FAILURE expected_to match_regex `9@` - SUCCESS expected_to_not match_regex `a@` - SUCCESS expected_to_not match_regex `C@` - SUCCESS expected_to_not match_regex `[[]0-9]@` - WARNING might match_regex `^1@2@4@9@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/range-pattern/003-ascii-range-1 (FAILED) - - Description: - The purpose of this test is to check if the bracket expansion works with the following pattern []-z]. - One test use the following range which is the default range for bash: - < > , ; : ! ' " ( ) [ ] { } @ $ \ # % 1 2 3 4 5 6 7 8 9 a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z - The other use the ascii value, which does make more sense. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch '2' 'a' 'B' 'c' 'Z' '[' ']' '[]-z]' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout []-z] - - STDOUT: - FAILURE expected_to match_regex `a@` - FAILURE expected_to match_regex `c@` - FAILURE expected_to match_regex `]@` - SUCCESS expected_to_not match_regex `2@` - SUCCESS expected_to_not match_regex `B@` - SUCCESS expected_to_not match_regex `Z@` - SUCCESS expected_to_not match_regex `[[]@` - SUCCESS expected_to_not match_regex `[[]]-z]@` - WARNING might match_regex `^]@a@c@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/range-pattern/004-ascii-range-2 (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with the following pattern `[1-z]`. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch '2' 'a' 'B' 'c' 'Z' ']' '[' '[1-z]' '1-z' '-' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [1-z] - - STDOUT: - FAILURE expected_to match_regex `2@` - FAILURE expected_to match_regex `a@` - FAILURE expected_to match_regex `B@` - FAILURE expected_to match_regex `c@` - FAILURE expected_to match_regex `Z@` - FAILURE expected_to match_regex `]@` - FAILURE expected_to match_regex `[[]@` - SUCCESS expected_to_not match_regex `-@` - SUCCESS expected_to_not match_regex `1-z@` - SUCCESS expected_to_not match_regex `[[]1-z]@` - WARNING might match_regex `^2@B@Z@[[]@]@a@c@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/simple-pattern/001-simple-list (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with a simple list of characters as pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'b' 'c' 'd' 'e' 'f' '[bca]' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [bca] - - STDOUT: - FAILURE expected_to match_regex `a@` - FAILURE expected_to match_regex `b@` - FAILURE expected_to match_regex `c@` - SUCCESS expected_to_not match_regex `d@` - SUCCESS expected_to_not match_regex `e@` - SUCCESS expected_to_not match_regex `f@` - SUCCESS expected_to_not match_regex `[[]bca]@` - WARNING might match_regex `^a@b@c@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/simple-pattern/002-multi-bracket (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with multiple brackets patterns. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch "TOKEN201703241737abcd" "TOKEN201703241737abc" "TOKEN201703241737abdc" "TOKEN201703241737b" "TOKEN201703241737" "TOKEN201703241737\[a]b\[c]\[d]" - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout TOKEN201703241737[a]b[c][d] - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737abcd@$` - SUCCESS expected_to_not match_regex `TOKEN201703241737abc@` - SUCCESS expected_to_not match_regex `TOKEN201703241737abdc@` - SUCCESS expected_to_not match_regex `TOKEN201703241737b@` - SUCCESS expected_to_not match_regex `TOKEN201703241737@` - SUCCESS expected_to_not match_regex `TOKEN201703241737[[]a]b[[]c][[]d]@` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/simple-pattern/003-brackets-as-pattern (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with an opening bracket `[` and a closing bracket `]` as pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch '[' ']' 'a' 'Z' '[][]' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [][] - - STDOUT: - FAILURE expected_to match_regex `[[]@` - FAILURE expected_to match_regex `]@` - SUCCESS expected_to_not match_regex `a@` - SUCCESS expected_to_not match_regex `Z@` - SUCCESS expected_to_not match_regex `[[]][[]]@` - WARNING might match_regex `^[[]@]@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/simple-pattern/004-multi-bracket-multi-char (FAILED) - - Description: - The purpose of this test is to match a file name which contain a bracket as first character. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 21 23 24 25 26 27 28 29 ']' '[' '[12][34]' '1234' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [12][34] - - STDOUT: - FAILURE expected_to match_regex `13@` - FAILURE expected_to match_regex `14@` - FAILURE expected_to match_regex `23@` - FAILURE expected_to match_regex `24@` - SUCCESS expected_to_not match_regex `0[0-9]@` - SUCCESS expected_to_not match_regex `1[0-2]@` - SUCCESS expected_to_not match_regex `1[5-9]@` - SUCCESS expected_to_not match_regex `2[0-2]@` - SUCCESS expected_to_not match_regex `2[5-9]@` - SUCCESS expected_to_not match_regex `[[]@` - SUCCESS expected_to_not match_regex `]@` - SUCCESS expected_to_not match_regex `[[]12][[]34]@` - SUCCESS expected_to_not match_regex `1234@` - WARNING might match_regex `^13@14@23@24@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/single-char-pattern/001-single-char (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with a single character as pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'b' '[a]' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [a] - - STDOUT: - FAILURE expected_to match_regex `a@` - SUCCESS expected_to_not match_regex `b@` - SUCCESS expected_to_not match_regex `[[]a]@` - WARNING might match_regex `^a@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/single-char-pattern/002-closing-bracket-char (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with a closing bracket `]` as pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch ']' '[]]' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout []] - - STDOUT: - FAILURE expected_to match_regex `]@` - SUCCESS expected_to_not match_regex `[[]]]@` - WARNING might match_regex `^]@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/globbing/bracket-expansion/single-char-pattern/003-opening-bracket-char (FAILED) - - Description: - The purpose of this test is to check that the brackets expansion works with an opening bracket `[` as pattern. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch '[' '[[]' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [[] - - STDOUT: - FAILURE expected_to match_regex `[[]@` - SUCCESS expected_to_not match_regex `[[][[]]@` - WARNING might match_regex `^[[]@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/local-variable/002-declare-and-expand-2 (FAILED) - - Description: - The purpose of this test is to check that an empty variable is not expanded as an empty string and results in any new argument in the command line. - - STDIN: - 01: TOKEN201703241737_NAME= - 02: ./write_on_stdout_and_stderr $TOKEN201703241737_NAME $TOKEN201703241737_NAME - - STDOUT: - FAILURE expected_to match_regex `write on stdout` - 01:  - - STDERR: - FAILURE expected_to match_regex `write on stderr` - 01:  - ----------------------------------------------------------------- - -42sh/local-variable/003-unknown-variable-does-not-result-in-new-argument (FAILED) - - Description: - The purpose of this test is to check that an unknown variable is not expanded as an empty string and results in any new argument in the command line. - - Before test: - 01: unset "TOKEN201703241737_UNKNOWN" - - STDIN: - 01: ./write_on_stdout $TOKEN201703241737_UNKNOWN TOKEN201703241737_DISPLAYED - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703241737_DISPLAYED` - 01: write on stdout - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/local-variable/004-existing-variable-in-environment-1 (FAILED) - - Description: - The purpose of this test is initialize a local variable named as an environment variable and check if it's update the existing environment variable. - - Before test: - 01: export "TOKEN201703241737_NAME=TOKEN201703241737_VALUE_OLD" - - STDIN: - 01: TOKEN201703241737_NAME=TOKEN201703241737_VALUE_NEW - 02: ./display_env - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737_NAME=TOKEN201703241737_VALUE_NEW$` - FAILURE expected_to_not match_regex `^TOKEN201703241737_NAME=TOKEN201703241737_VALUE_OLD$` - 01: ------------------------------ - 02: TERM_PROGRAM=iTerm.app - 03: TOKEN201703241737_NAME=TOKEN201703241737_VALUE_OLD - 04: TERM=screen-256color - 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 - 09: TERM_PROGRAM_VERSION=3.0.10 - 10: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 11: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 12: ZSH=/Users/ariard/.oh-my-zsh - 13: USER=ariard - 14: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 15: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 16: PAGER=less - 17: TMUX=/private/tmp/tmux-18965/default,73780,2 - 18: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 19: LSCOLORS=Gxfxcxdxbxegedabagacad - 20: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 21: MAIL=ariard@student.42.fr - 22: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 23: LANG=en_US.UTF-8 - 24: ITERM_PROFILE=Default - 25: XPC_FLAGS=0x0 - 26: TMUX_PANE=%9 - 27: XPC_SERVICE_NAME=0 - 28: SHLVL=4 - 29: HOME=/Users/ariard - 30: COLORFGBG=7;0 - 31: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 32: LOGNAME=ariard - 33: LESS=-R - 34: LC_CTYPE=en_US.UTF-8 - 35: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 36: _=../../42sh - 37: ?=0 - 38: ------------------------------ - 39: TOTAL ENVIRONMENT VARIABLES: 36 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/local-variable/005-existing-variable-in-environment-2 (FAILED) - - Description: - The purpose of this test is initialize a local variable named as an environment variable and check if it's update the existing environment variable. - - Before test: - 01: export "TOKEN201703241737_NAME=TOKEN201703241737_VALUE" - - STDIN: - 01: TOKEN201703241737_NAME= - 02: ./display_env - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737_NAME=$` - FAILURE expected_to_not match_regex `^TOKEN201703241737_NAME=TOKEN201703241737_VALUE$` - 01: ------------------------------ - 02: TERM_PROGRAM=iTerm.app - 03: TOKEN201703241737_NAME=TOKEN201703241737_VALUE - 04: TERM=screen-256color - 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 - 09: TERM_PROGRAM_VERSION=3.0.10 - 10: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 11: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 12: ZSH=/Users/ariard/.oh-my-zsh - 13: USER=ariard - 14: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 15: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 16: PAGER=less - 17: TMUX=/private/tmp/tmux-18965/default,73780,2 - 18: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 19: LSCOLORS=Gxfxcxdxbxegedabagacad - 20: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 21: MAIL=ariard@student.42.fr - 22: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 23: LANG=en_US.UTF-8 - 24: ITERM_PROFILE=Default - 25: XPC_FLAGS=0x0 - 26: TMUX_PANE=%9 - 27: XPC_SERVICE_NAME=0 - 28: SHLVL=4 - 29: HOME=/Users/ariard - 30: COLORFGBG=7;0 - 31: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 32: LOGNAME=ariard - 33: LESS=-R - 34: LC_CTYPE=en_US.UTF-8 - 35: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 36: _=../../42sh - 37: ?=0 - 38: ------------------------------ - 39: TOTAL ENVIRONMENT VARIABLES: 36 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/local-variable/007-multiple-declaration-at-a-time (FAILED) - - Description: - The purpose of this test is to check that declaring multiple variables in the same command line does work. - - STDIN: - 01: TOKEN201703241737_NAME1=TOKEN201703241737_VALUE1 TOKEN201703241737_NAME2=TOKEN201703241737_VALUE2 TOKEN201703241737_NAME3=TOKEN201703241737_VALUE3 - 02: ./write_on_stdout_and_stderr $TOKEN201703241737_NAME1 $TOKEN201703241737_NAME1 - 03: ./write_on_stdout $TOKEN201703241737_NAME2 - 04: ./write_on_stderr $TOKEN201703241737_NAME3 - - STDOUT: - SUCCESS expected_to match_regex `^TOKEN201703241737_VALUE1$` - FAILURE expected_to match_regex `^TOKEN201703241737_VALUE2$` - SUCCESS expected_to_not match_regex `^TOKEN201703241737_VALUE3$` - 01: TOKEN201703241737_VALUE1 - 02:  - - STDERR: - SUCCESS expected_to match_regex `^TOKEN201703241737_VALUE1$` - SUCCESS expected_to_not match_regex `^TOKEN201703241737_VALUE2$` - FAILURE expected_to match_regex `^TOKEN201703241737_VALUE3$` - 01: TOKEN201703241737_VALUE1 - 02:  - ----------------------------------------------------------------- - -42sh/local-variable/008-multiple-declaration-with-same-name (FAILED) - - Description: - The purpose of this test is to check that declaring the same variable several times in the same command line does work and does not result in error. - - STDIN: - 01: TOKEN201703241737_NAME=TOKEN201703241737_VALUE1 TOKEN201703241737_NAME=TOKEN201703241737_VALUE2 TOKEN201703241737_NAME=TOKEN201703241737_VALUE3 - 02: ./write_on_stdout $TOKEN201703241737_NAME - - STDOUT: - FAILURE expected_to_not match_regex `^TOKEN201703241737_VALUE1$` - SUCCESS expected_to_not match_regex `^TOKEN201703241737_VALUE2$` - FAILURE expected_to match_regex `^TOKEN201703241737_VALUE3$` - 01: TOKEN201703241737_VALUE1 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/local-variable/mixed/inline-environment-variable/001-local-variable-shouldnt-be-set (FAILED) - - Description: - The purpose of this test is to check that declaring a variable and specifying a binary does not result in local variable declaration but a modified environment for the command. - - STDIN: - 01: TOKEN201703241737_NAME=TOKEN201703241737_VALUE ./display_env - 02: ./write_on_stderr $TOKEN201703241737 - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737_NAME=TOKEN201703241737_VALUE$` - (no output) - - STDERR: - FAILURE expected_to_not match_regex `TOKEN201703241737_VALUE` - FAILURE expected_to match_regex `write on stderr` - 01: ../../42sh: command not found: TOKEN201703241737_NAME=TOKEN201703241737_VALUE - 02:  - ----------------------------------------------------------------- - -42sh/local-variable/mixed/redirections/001-truncating (FAILED) - - Description: - The purpose of this test is to check that a redirection can be set with a local variable as file name. - - Before test: - 01: rm -f "TOKEN201703241737_FILENAME" - - STDIN: - 01: TOKEN201703241737_NAME=TOKEN201703241737_FILENAME - 02: ./write_on_stdout TOKEN201703241737_VALUE > $TOKEN201703241737_NAME - - STDOUT: - SUCCESS expected_to be_empty - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - - MISC: - FAILURE expected_to create_file `TOKEN201703241737_FILENAME` matching_regex `^TOKEN201703241737_VALUE$` - SUCCESS expected_to exit_with_status `0` - ----------------------------------------------------------------- - -42sh/local-variable/mixed/redirections/002-appending (FAILED) - - Description: - The purpose of this test is to check that a redirection can be set with a local variable as file name. - - Before test: - 01: rm -f "TOKEN201703241737_FILENAME" - - STDIN: - 01: TOKEN201703241737_NAME=TOKEN201703241737_FILENAME - 02: ./write_on_stdout TOKEN201703241737_VALUE1 >> $TOKEN201703241737_NAME - 03: ./write_on_stdout TOKEN201703241737_VALUE2 >> $TOKEN201703241737_NAME - - STDOUT: - SUCCESS expected_to be_empty - (no output) - - STDERR: - SUCCESS expected_to be_empty - (no output) - - MISC: - FAILURE expected_to create_file `TOKEN201703241737_FILENAME` matching_regex `^TOKEN201703241737_VALUE1$` - FAILURE expected_to create_file `TOKEN201703241737_FILENAME` matching_regex `^TOKEN201703241737_VALUE2$` - SUCCESS expected_to exit_with_status `0` - ----------------------------------------------------------------- - -42sh/local-variable/mixed/tilde-expansion/001-process-tilde-expansion (FAILED) - - Description: - The purpose of this test is to check that the tilde expansion `~` in variable declaration. - - Before test: - 01: export "HOME=/TOKEN201703241737" - - STDIN: - 01: TOKEN201703241737=~ - 02: ./write_on_stdout TILDE:$TOKEN201703241737 - - STDOUT: - FAILURE expected_to_not match_regex `TILDE:~` - WARNING might match_regex `TILDE:/TOKEN201703241737` - 01: TILDE:~ - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/escaping/002-escape-double-quote-2 (FAILED) - - Description: - The purpose of this test is to check that a double-quote `"` may be preserved when it is preceded by a backslash `\\`. - - STDIN: - 01: ./write_on_stdout "TOKEN201703241737 \" TOKEN201703241737" - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737 ` TOKEN201703241737$` - 01: TOKEN201703241737 TOKEN201703241737 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/escaping/003-escape-double-quote-3 (FAILED) - - Description: - The purpose of this test is to check that a double-quote `"` may be preserved when it is preceded by a backslash `\\`. - - STDIN: - 01: ./write_on_stdout "\"" - - STDOUT: - FAILURE expected_to match_regex `^"$` - 01:  - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/escaping/004-it-results-in-error (FAILED) - - Description: - The purpose of this test is to check that using backslash `\\` before the closing double-quote `"` does result in syntax error. - - STDIN: - 01: ./write_on_stdout "TOKEN201703241737\" - - STDOUT: - SUCCESS expected_to_not match_regex `^TOKEN201703241737$` - (no output) - - STDERR: - FAILURE expected_to_not be_empty - WARNING might match_regex `([Ss]yntax|[Pp]arse) error` - (no output) - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/escaping/005-it-does-not-escape-double-quote (FAILED) - - Description: - The purpose of this test is to check that using two backslashes `\\` before the symbol double-quote `"` does not result in escaped inhibitors. - - STDIN: - 01: ./write_on_stdout \\"TOKEN201703241737\\" - - STDOUT: - FAILURE expected_to match_regex `^\TOKEN201703241737\$` - 01: \TOKEN201703241737 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/globbing/brace-expansion/002-it-does-not-expand-braces-2 (FAILED) - - Description: - The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. - - STDIN: - 01: ./write_all_arguments_on_stdout {1..2}"{1..2}" - - STDOUT: - FAILURE expected_to match_regex `1[{]1..2}@2[{]1..2}@` - 01: {1..2}{1..2}@ - - STDERR: - (no output) - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/globbing/brace-expansion/003-it-does-not-expand-braces-3 (FAILED) - - Description: - The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. - - STDIN: - 01: ./write_all_arguments_on_stdout "{1..2}"{1..2} - - STDOUT: - FAILURE expected_to match_regex `[{]1..2}1@[{]1..2}2@` - 01: {1..2}{1..2}@ - - STDERR: - (no output) - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/globbing/brace-expansion/004-it-does-not-expand-braces-4 (FAILED) - - Description: - The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. - - STDIN: - 01: ./write_all_arguments_on_stdout "{1..2}"{1..2}"{1..2}"{1..2}"{1..2}"{1..2} - - STDOUT: - FAILURE expected_to match_regex `[{]1..2}1[{]1..2}1[{]1..2}1@[{]1..2}1[{]1..2}1[{]1..2}2@[{]1..2}1[{]1..2}2[{]1..2}1@[{]1..2}1[{]1..2}2[{]1..2}2@[{]1..2}2[{]1..2}1[{]1..2}1@[{]1..2}2[{]1..2}1[{]1..2}2@[{]1..2}2[{]1..2}2[{]1..2}1@[{]1..2}2[{]1..2}2[{]1..2}2@` - 01: {1..2}{1..2}{1..2}{1..2}{1..2}{1..2}@ - - STDERR: - (no output) - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/globbing/brace-expansion/005-it-does-not-expand-braces-5 (FAILED) - - Description: - The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. - - STDIN: - 01: ./write_all_arguments_on_stdout "{1..2}" {1..2} "{1..2}" "{1..2}" - - STDOUT: - FAILURE expected_to match_regex `[{]1..2}@1@2@[{]1..2}@[{]1..2}@` - 01: {1..2}@{1..2}@{1..2}@{1..2}@ - - STDERR: - (no output) - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/globbing/bracket-expansion/001-it-works-1 (FAILED) - - Description: - The purpose of this test is to check that an argument made with quoted and unquoted parts results in bracket pattern expansion. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout ["a"] - - STDOUT: - SUCCESS expected_to_not match_regex `[[]a]@` - FAILURE expected_to match_regex `^a@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/quoting/double-quotes/mixed/globbing/bracket-expansion/002-it-works-2 (FAILED) - - Description: - The purpose of this test is to check that an argument made with quoted and unquoted parts results in bracket pattern expansion. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout ["a"bc"def"gh] - - STDOUT: - FAILURE expected_to match_regex `a@` - FAILURE expected_to match_regex `b@` - FAILURE expected_to match_regex `c@` - FAILURE expected_to match_regex `d@` - FAILURE expected_to match_regex `e@` - FAILURE expected_to match_regex `f@` - FAILURE expected_to match_regex `g@` - FAILURE expected_to match_regex `h@` - SUCCESS expected_to_not match_regex `bc` - SUCCESS expected_to_not match_regex `def` - SUCCESS expected_to_not match_regex `gh` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/quoting/mixed/globbing/brace-expansion/001-it-does-not-expand-braces-1 (FAILED) - - Description: - The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. - - STDIN: - 01: ./write_all_arguments_on_stdout "{1..2}"{1..2}'{1..2}'{1..2}"{1..2}"{1..2} - - STDOUT: - FAILURE expected_to match_regex `[{]1..2}1[{]1..2}1[{]1..2}1@[{]1..2}1[{]1..2}1[{]1..2}2@[{]1..2}1[{]1..2}2[{]1..2}1@[{]1..2}1[{]1..2}2[{]1..2}2@[{]1..2}2[{]1..2}1[{]1..2}1@[{]1..2}2[{]1..2}1[{]1..2}2@[{]1..2}2[{]1..2}2[{]1..2}1@[{]1..2}2[{]1..2}2[{]1..2}2@` - 01: {1..2}{1..2}{1..2}{1..2}{1..2}{1..2}@ - - STDERR: - (no output) - ----------------------------------------------------------------- - -42sh/quoting/mixed/globbing/bracket-expansion/001-it-works-1 (FAILED) - - Description: - The purpose of this test is to check that an argument made with quoted and unquoted parts results in bracket pattern expansion. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout [""'a'""] - - STDOUT: - SUCCESS expected_to_not match_regex `[[]a]@` - FAILURE expected_to match_regex `^a@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/quoting/mixed/globbing/bracket-expansion/002-it-works-2 (FAILED) - - Description: - The purpose of this test is to check that an argument made with quoted and unquoted parts results in bracket pattern expansion. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout ["a"bc'def'gh] - - STDOUT: - FAILURE expected_to match_regex `a@` - FAILURE expected_to match_regex `b@` - FAILURE expected_to match_regex `c@` - FAILURE expected_to match_regex `d@` - FAILURE expected_to match_regex `e@` - FAILURE expected_to match_regex `f@` - FAILURE expected_to match_regex `g@` - FAILURE expected_to match_regex `h@` - SUCCESS expected_to_not match_regex `bc` - SUCCESS expected_to_not match_regex `def` - SUCCESS expected_to_not match_regex `gh` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/quoting/mixed/variable-expansion/001-it-does-not-expand-in-quotes (FAILED) - - Description: - The purpose of this test is to check if a local variable is display correctly inside simple and double quote. - - Before test: - 01: export "TOKEN201703241737_NAME=TOKEN201703241737_VALUE" - - STDIN: - 01: ./write_on_stdout "$TOKEN201703241737_NAME"$TOKEN201703241737_NAME'$TOKEN201703241737_NAME' - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703241737_VALUETOKEN201703241737_VALUE[$]TOKEN201703241737_NAME` - 01: TOKEN201703241737_VALUEE$TOKEN201703241737_NAME - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/002-it-does-not-expand-braces-2 (FAILED) - - Description: - The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. - - STDIN: - 01: ./write_all_arguments_on_stdout {1..2}'{1..2}' - - STDOUT: - FAILURE expected_to match_regex `1[{]1..2}@2[{]1..2}@` - 01: {1..2}{1..2}@ - - STDERR: - (no output) - ----------------------------------------------------------------- - -42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/003-it-does-not-expand-braces-3 (FAILED) - - Description: - The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. - - STDIN: - 01: ./write_all_arguments_on_stdout '{1..2}'{1..2} - - STDOUT: - FAILURE expected_to match_regex `[{]1..2}1@[{]1..2}2@` - 01: {1..2}{1..2}@ - - STDERR: - (no output) - ----------------------------------------------------------------- - -42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/004-it-does-not-expand-braces-4 (FAILED) - - Description: - The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. - - STDIN: - 01: ./write_all_arguments_on_stdout '{1..2}'{1..2}'{1..2}'{1..2}'{1..2}'{1..2} - - STDOUT: - FAILURE expected_to match_regex `[{]1..2}1[{]1..2}1[{]1..2}1@[{]1..2}1[{]1..2}1[{]1..2}2@[{]1..2}1[{]1..2}2[{]1..2}1@[{]1..2}1[{]1..2}2[{]1..2}2@[{]1..2}2[{]1..2}1[{]1..2}1@[{]1..2}2[{]1..2}1[{]1..2}2@[{]1..2}2[{]1..2}2[{]1..2}1@[{]1..2}2[{]1..2}2[{]1..2}2@` - 01: {1..2}{1..2}{1..2}{1..2}{1..2}{1..2}@ - - STDERR: - (no output) - ----------------------------------------------------------------- - -42sh/quoting/simple-quotes/mixed/globbing/brace-expansion/005-it-does-not-expand-braces-5 (FAILED) - - Description: - The purpose of this test is to check that braces expansion is not processed within quoted part of the command line. - - STDIN: - 01: ./write_all_arguments_on_stdout '{1..2}' {1..2} '{1..2}' '{1..2}' - - STDOUT: - FAILURE expected_to match_regex `[{]1..2}@1@2@[{]1..2}@[{]1..2}@` - 01: {1..2}@{1..2}@{1..2}@{1..2}@ - - STDERR: - (no output) - ----------------------------------------------------------------- - -42sh/quoting/simple-quotes/mixed/globbing/bracket-expansion/001-it-works-1 (FAILED) - - Description: - The purpose of this test is to check that an argument made with quoted and unquoted parts results in bracket pattern expansion. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout ['a'] - - STDOUT: - SUCCESS expected_to_not match_regex `[[]a]@` - FAILURE expected_to match_regex `^a@$` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/quoting/simple-quotes/mixed/globbing/bracket-expansion/002-it-works-2 (FAILED) - - Description: - The purpose of this test is to check that an argument made with quoted and unquoted parts results in bracket pattern expansion. - - Before test: - 01: rm -rf "./test_globbing" - 02: mkdir "./test_globbing" - 03: cd "./test_globbing" - 04: touch 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' - - STDIN: - 01: /Users/ariard/Projects/42sh/42ShellTester/tmp/write_all_arguments_on_stdout ['a'bc'def'gh] - - STDOUT: - FAILURE expected_to match_regex `a@` - FAILURE expected_to match_regex `b@` - FAILURE expected_to match_regex `c@` - FAILURE expected_to match_regex `d@` - FAILURE expected_to match_regex `e@` - FAILURE expected_to match_regex `f@` - FAILURE expected_to match_regex `g@` - FAILURE expected_to match_regex `h@` - SUCCESS expected_to_not match_regex `bc` - SUCCESS expected_to_not match_regex `def` - SUCCESS expected_to_not match_regex `gh` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ./lib/main.sh: line 102: ../../42sh: No such file or directory - ----------------------------------------------------------------- - -42sh/subshell/mixed/inline-environment-variable/001-modifies-the-child-environment-only-1 (FAILED) - - Description: - The purpose of this test is to check that declaring a variable and specifying a binary in a subshell does not result in local variable declaration or a modified parent shell's environment, but only a modified child's environment. - - STDIN: - 01: (TOKEN201703241737_NAME=TOKEN201703241737_VALUE ./display_env) - 02: ./display_env - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737_NAME=TOKEN201703241737_VALUE$` once - 01: ------------------------------ - 02: TERM_PROGRAM=iTerm.app - 03: TERM=screen-256color - 04: SHELL=/bin/zsh - 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render - 08: TERM_PROGRAM_VERSION=3.0.10 - 09: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 10: ZSH=/Users/ariard/.oh-my-zsh - 11: USER=ariard - 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 14: PAGER=less - 15: TMUX=/private/tmp/tmux-18965/default,73780,2 - 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 17: LSCOLORS=Gxfxcxdxbxegedabagacad - 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 19: MAIL=ariard@student.42.fr - 20: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 21: LANG=en_US.UTF-8 - 22: ITERM_PROFILE=Default - 23: XPC_FLAGS=0x0 - 24: TMUX_PANE=%9 - 25: XPC_SERVICE_NAME=0 - 26: SHLVL=4 - 27: HOME=/Users/ariard - 28: COLORFGBG=7;0 - 29: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 30: LOGNAME=ariard - 31: LESS=-R - 32: LC_CTYPE=en_US.UTF-8 - 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 34: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 35: _=../../42sh - 36: ?=127 - 37: ------------------------------ - 38: TOTAL ENVIRONMENT VARIABLES: 35 - - STDERR: - FAILURE expected_to be_empty - 01: ../../42sh: command not found: TOKEN201703241737_NAME=TOKEN201703241737_VALUE - ----------------------------------------------------------------- - -42sh/subshell/mixed/inline-environment-variable/002-modifies-the-child-environment-only-2 (FAILED) - - Description: - The purpose of this test is to check that declaring a variable and specifying a binary in a subshell does not result in local variable declaration or a modified parent shell's environment, but only a modified child's environment. - - STDIN: - 01: ( (TOKEN201703241737_NAME=TOKEN201703241737_VALUE ./display_env) ; ./display_env) ; ./display_env - 02:  - - STDOUT: - FAILURE expected_to match_regex `^TOKEN201703241737_NAME=TOKEN201703241737_VALUE$` once - 01: ------------------------------ - 02: TERM_PROGRAM=iTerm.app - 03: TERM=screen-256color - 04: SHELL=/bin/zsh - 05: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 06: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 07: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render - 08: TERM_PROGRAM_VERSION=3.0.10 - 09: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 10: ZSH=/Users/ariard/.oh-my-zsh - 11: USER=ariard - 12: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 13: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 14: PAGER=less - 15: TMUX=/private/tmp/tmux-18965/default,73780,2 - 16: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 17: LSCOLORS=Gxfxcxdxbxegedabagacad - 18: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 19: MAIL=ariard@student.42.fr - 20: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 21: LANG=en_US.UTF-8 - 22: ITERM_PROFILE=Default - 23: XPC_FLAGS=0x0 - 24: TMUX_PANE=%9 - 25: XPC_SERVICE_NAME=0 - 26: SHLVL=4 - 27: HOME=/Users/ariard - 28: COLORFGBG=7;0 - 29: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 30: LOGNAME=ariard - 31: LESS=-R - 32: LC_CTYPE=en_US.UTF-8 - 33: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 34: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 35: _=../../42sh - 36: ?=127 - 37: ------------------------------ - 38: TOTAL ENVIRONMENT VARIABLES: 35 - 39: ------------------------------ - 40: TERM_PROGRAM=iTerm.app - 41: TERM=screen-256color - 42: SHELL=/bin/zsh - 43: HOMEBREW_TEMP=/tmp/ariard/Homebrew/Temp - 44: TMPDIR=/var/folders/zz/zyxvpxvq6csfxvn_n0002_2m000khn/T/ - 45: Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.LmcFivfwkY/Render - 46: TERM_PROGRAM_VERSION=3.0.10 - 47: TERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 48: ZSH=/Users/ariard/.oh-my-zsh - 49: USER=ariard - 50: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u4JR4EZzBG/Listeners - 51: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 52: PAGER=less - 53: TMUX=/private/tmp/tmux-18965/default,73780,2 - 54: HOMEBREW_CACHE=/tmp/ariard/Homebrew/Caches - 55: LSCOLORS=Gxfxcxdxbxegedabagacad - 56: PATH=/Users/ariard/.brew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki://Users/ariard/local/bin - 57: MAIL=ariard@student.42.fr - 58: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 59: LANG=en_US.UTF-8 - 60: ITERM_PROFILE=Default - 61: XPC_FLAGS=0x0 - 62: TMUX_PANE=%9 - 63: XPC_SERVICE_NAME=0 - 64: SHLVL=4 - 65: HOME=/Users/ariard - 66: COLORFGBG=7;0 - 67: ITERM_SESSION_ID=w0t0p1:D3D230F7-7E75-4A5C-B793-6A5C4DAD3F83 - 68: LOGNAME=ariard - 69: LESS=-R - 70: LC_CTYPE=en_US.UTF-8 - 71: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 72: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester - 73: _=../../42sh - 74: ?=0 - 75: ------------------------------ - 76: TOTAL ENVIRONMENT VARIABLES: 35 - - STDERR: - FAILURE expected_to be_empty - 01: ../../42sh: command not found: TOKEN201703241737_NAME=TOKEN201703241737_VALUE - -Total tests: 162 -Total failed tests: 92 -Total pending tests: 0 diff --git a/42sh/Makefile b/42sh/Makefile index 36d1d3b0..6dedd814 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,14 +6,14 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -# Updated: 2017/03/26 22:15:25 by jhalford ### ########.fr # +# Updated: 2017/03/27 03:12:30 by ariard ### ########.fr # # # # **************************************************************************** # NAME = 42sh CC = gcc -FLAGS = -Wall -Wextra -Werror -fsanitize=address +FLAGS = -Wall -Wextra -Werror #-fsanitize=address D_FLAGS = -g DELTA = $$(echo "$$(tput cols)-47"|bc) diff --git a/42sh/file b/42sh/file new file mode 100644 index 00000000..8bccba03 --- /dev/null +++ b/42sh/file @@ -0,0 +1 @@ +GAGNE diff --git a/42sh/file1 b/42sh/file1 new file mode 100644 index 00000000..760b375e --- /dev/null +++ b/42sh/file1 @@ -0,0 +1,20 @@ +42ShellTester +42sh +Makefile +README.md +STDBUG +auteur +donovan_segaults_06-02 +file1 +includes +libft +minishell_error +objs +other +pdf +sample +scriptheader.sh +src +test +test.sh +update_makefile.sh diff --git a/42sh/other b/42sh/other new file mode 100644 index 00000000..15118256 --- /dev/null +++ b/42sh/other @@ -0,0 +1 @@ +cat: stdout: Bad file descriptor diff --git a/42sh/src/exec/plaunch_case.c b/42sh/src/exec/plaunch_case.c index 7c23b356..3d3692ca 100644 --- a/42sh/src/exec/plaunch_case.c +++ b/42sh/src/exec/plaunch_case.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 19:02:23 by wescande #+# #+# */ -/* Updated: 2017/03/22 22:00:16 by ariard ### ########.fr */ +/* Updated: 2017/03/27 03:47:36 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,8 @@ int plaunch_case(t_process *p) exec = &data_singleton()->exec; exec->attrs &= ~EXEC_CASE_BRANCH; + if (exec->case_pattern && *exec->case_pattern) + ft_tabdel(&exec->case_pattern); exec->case_pattern = token_to_argv(p->data.d_case.token, 1); ft_exec(&p->data.d_case.content); ft_tabdel(&exec->case_pattern); diff --git a/42sh/src/exec/pset_case.c b/42sh/src/exec/pset_case.c index c439fb2e..20602607 100644 --- a/42sh/src/exec/pset_case.c +++ b/42sh/src/exec/pset_case.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 20:36:04 by wescande #+# #+# */ -/* Updated: 2017/03/23 00:31:39 by ariard ### ########.fr */ +/* Updated: 2017/03/27 03:42:29 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/test.c b/42sh/test.c new file mode 100644 index 00000000..2adb839e --- /dev/null +++ b/42sh/test.c @@ -0,0 +1,10 @@ +#include "stdio.h" +#include "string.h" + +int main(void) +{ + char str[10]; + + strcpy(str, "aaaaaaaaaaaaaaaaaaaaaaaa"); + return (0); +} diff --git a/42sh/test.sh b/42sh/test.sh new file mode 100644 index 00000000..0e9b1b95 --- /dev/null +++ b/42sh/test.sh @@ -0,0 +1 @@ +ls | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e diff --git a/42sh/test/fifi b/42sh/test/fifi new file mode 100644 index 00000000..e69de29b diff --git a/42sh/test1 b/42sh/test1 new file mode 100644 index 00000000..23313b66 --- /dev/null +++ b/42sh/test1 @@ -0,0 +1,24 @@ +42ShellTester +42sh +Makefile +README.md +STDBUG +auteur +donovan_segaults_06-02 +file +file1 +includes +libft +minishell_error +objs +other +pdf +sample +scriptheader.sh +src +test +test.c +test.sh +test1 +update_makefile.sh +/Users/ariard/Projects/42sh From 5ff07e438c53ee0e3e68dc4b13f7affda97a88f4 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 27 Mar 2017 03:49:09 +0200 Subject: [PATCH 03/18] case loop no more leaks --- 42sh/file | 1 - 42sh/file1 | 20 --- 42sh/minishell_error | 332 ------------------------------------------- 42sh/other | 1 - 42sh/test.c | 10 -- 42sh/test.sh | 1 - 42sh/test1 | 24 ---- 7 files changed, 389 deletions(-) delete mode 100644 42sh/file delete mode 100644 42sh/file1 delete mode 100644 42sh/minishell_error delete mode 100644 42sh/other delete mode 100644 42sh/test.c delete mode 100644 42sh/test.sh delete mode 100644 42sh/test1 diff --git a/42sh/file b/42sh/file deleted file mode 100644 index 8bccba03..00000000 --- a/42sh/file +++ /dev/null @@ -1 +0,0 @@ -GAGNE diff --git a/42sh/file1 b/42sh/file1 deleted file mode 100644 index 760b375e..00000000 --- a/42sh/file1 +++ /dev/null @@ -1,20 +0,0 @@ -42ShellTester -42sh -Makefile -README.md -STDBUG -auteur -donovan_segaults_06-02 -file1 -includes -libft -minishell_error -objs -other -pdf -sample -scriptheader.sh -src -test -test.sh -update_makefile.sh diff --git a/42sh/minishell_error b/42sh/minishell_error deleted file mode 100644 index 883caec1..00000000 --- a/42sh/minishell_error +++ /dev/null @@ -1,332 +0,0 @@ -...x...~......xx....~.~.~......x....x.....x........... - ----------------------------------------------------------------- - -minishell/binary/004-binary-test-empty-path (FAILED) - - Description: - The purpose of this test is to check that the Shell finds binaries that are located in the current directory when the environment variable PATH is empty. - - Before test: - 01: export PATH="" - - STDIN: - 01: write_on_stdout "TOKEN201703242314" - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703242314` - (no output) - - STDERR: - FAILURE expected_to be_empty - 01: ../../42sh: command not found: write_on_stdout - - MISC: - FAILURE expected_to exit_with_status `0` - ----------------------------------------------------------------- - -minishell/binary/008-binary-too-many-symbolic-links-encountered (WARNING) - - Description: - The purpose of this test is to check that trying to execute a path that encounters an infinite loop of symbolic link results in an error on standard error and a failure exit status. - - Before test: - 01: rm -rf ./symbolic_link1 ./symbolic_link2 ./symbolic_link3 - 02: ln -s ./symbolic_link1 ./symbolic_link2 - 03: ln -s ./symbolic_link2 ./symbolic_link3 - 04: ln -s ./symbolic_link3 ./symbolic_link1 - - STDIN: - 01: ./symbolic_link1 - - STDOUT: - SUCCESS might be_empty - (no output) - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `[Tt]oo many.*symbolic links` - 01: ../../42sh: ./symbolic_link1: no such file or directory - - MISC: - SUCCESS expected_to_not exit_with_status 0 - ----------------------------------------------------------------- - -minishell/builtins/cd/007-symbolic-link (FAILED) - - Description: - The purpose of this test is to check that using a symbolic link as first argument with the builtin `cd` results in moving the linked directory. - - Before test: - 01: rm -f "./symbolic_link" - 02: mkdir -p "./sub_directory" - 03: ln -s "./sub_directory" "./symbolic_link" - - STDIN: - 01: cd symbolic_link - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - 03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_env - - STDOUT: - SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD$` - FAILURE expected_to match_regex `^PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/symbolic_link$` - 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD - 02: ------------------------------ - 03: TERM_PROGRAM=iTerm.app - 04: TERM=screen-256color - 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.UJksyURLXc/Render - 09: TERM_PROGRAM_VERSION=3.0.10 - 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.zEo8Maujhn/Listeners - 14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 15: PAGER=less - 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 - 20: MAIL=ariard@student.42.fr - 21: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory - 22: LANG=en_US.UTF-8 - 23: ITERM_PROFILE=Default - 24: XPC_FLAGS=0x0 - 25: TMUX_PANE=%9 - 26: XPC_SERVICE_NAME=0 - 27: SHLVL=4 - 28: HOME=/Users/ariard - 29: COLORFGBG=7;0 - 30: ITERM_SESSION_ID=w0t0p0:162D7F62-BEB1-405A-B3D5-E18A8A96E577 - 31: LOGNAME=ariard - 32: LESS=-R - 33: LC_CTYPE=en_US.UTF-8 - 34: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 35: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 36: _=../../42sh - 37: ?=0 - 38: ------------------------------ - 39: TOTAL ENVIRONMENT VARIABLES: 35 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -minishell/builtins/cd/008-symbolic-link-2 (FAILED) - - Description: - The purpose of this test is to check that using a symbolic link as first argument with the builtin `cd` results in moving to the linked directory. In this test, the directory is linked with to chained symbolic links. - - Before test: - 01: rm -f "./symbolic_link1" "./symbolic_link2" - 02: mkdir -p "./sub_directory" - 03: ln -s "./sub_directory" "./symbolic_link1" - 04: ln -s "./symbolic_link1" "./symbolic_link2" - - STDIN: - 01: cd symbolic_link2 - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - 03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_env - - STDOUT: - SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD$` - FAILURE expected_to match_regex `^PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/symbolic_link2$` - 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory:PWD - 02: ------------------------------ - 03: TERM_PROGRAM=iTerm.app - 04: TERM=screen-256color - 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.UJksyURLXc/Render - 09: TERM_PROGRAM_VERSION=3.0.10 - 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.zEo8Maujhn/Listeners - 14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 - 15: PAGER=less - 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 - 20: MAIL=ariard@student.42.fr - 21: PWD=/Users/ariard/Projects/42sh/42ShellTester/tmp/sub_directory - 22: LANG=en_US.UTF-8 - 23: ITERM_PROFILE=Default - 24: XPC_FLAGS=0x0 - 25: TMUX_PANE=%9 - 26: XPC_SERVICE_NAME=0 - 27: SHLVL=4 - 28: HOME=/Users/ariard - 29: COLORFGBG=7;0 - 30: ITERM_SESSION_ID=w0t0p0:162D7F62-BEB1-405A-B3D5-E18A8A96E577 - 31: LOGNAME=ariard - 32: LESS=-R - 33: LC_CTYPE=en_US.UTF-8 - 34: TMUX_PLUGIN_MANAGER_PATH=/Users/ariard/.tmux/plugins/ - 35: OLDPWD=/Users/ariard/Projects/42sh/42ShellTester/tmp - 36: _=../../42sh - 37: ?=0 - 38: ------------------------------ - 39: TOTAL ENVIRONMENT VARIABLES: 35 - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -minishell/builtins/cd/errors/001-not-a-directory (WARNING) - - Description: - The purpose of this test is to check that using a file name as first argument with the builtin `cd` results in error and not changing current directory. - - Before test: - 01: touch "./not_a_directory" - - STDIN: - 01: cd not_a_directory - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - - STDOUT: - SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD` - 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `[Nn]ot a directory` - 01: ../../42sh: cd: no such file or directory: not_a_directory - ----------------------------------------------------------------- - -minishell/builtins/cd/errors/003-permission-denied (WARNING) - - Description: - The purpose of this test is to check that using a directory without any permission as first argument with the builtin `cd` results in error and not changing current directory. - - Before test: - 01: if [ -d "./permission_denied" ]; then chmod 777 "./permission_denied"; fi - 02: rm -rf "./permission_denied" - 03: mkdir -m 0 "./permission_denied" - - STDIN: - 01: cd permission_denied - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - - STDOUT: - SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD` - 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `[Pp]ermission denied` - 01: ../../42sh: cd: no such file or directory: permission_denied - - After test: - 01: if [ -d "./permission_denied" ]; then chmod 777 "./permission_denied"; fi - 02: rm -rf "./permission_denied" - ----------------------------------------------------------------- - -minishell/builtins/cd/errors/005-too-many-symbolic-links-encountered (WARNING) - - Description: - The purpose of this test is to check that using a symbolic link resulting in ELOOP error as first argument with the builtin `cd` results in error and not changing current directory. - - Before test: - 01: rm -f "./symbolic_link1" "./symbolic_link2" "./symbolic_link3" - 02: ln -s "./symbolic_link1" "./symbolic_link2" - 03: ln -s "./symbolic_link2" "./symbolic_link3" - 04: ln -s "./symbolic_link3" "./symbolic_link1" - - STDIN: - 01: cd symbolic_link1 - 02: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - - STDOUT: - SUCCESS expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD` - 01: PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `[Tt]oo many.*symbolic links` - 01: ../../42sh: cd: no such file or directory: symbolic_link1 - ----------------------------------------------------------------- - -minishell/builtins/cd/options/002-oldpwd (FAILED) - - Description: - 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: cd / - 02: cd - - 03: /Users/ariard/Projects/42sh/42ShellTester/tmp/display_pwd - - STDOUT: - FAILURE expected_to match_regex `PWD:/Users/ariard/Projects/42sh/42ShellTester/tmp:PWD` - 01: /Users/ariard - 02: PWD:/Users/ariard:PWD - - STDERR: - SUCCESS expected_to be_empty - (no output) - ----------------------------------------------------------------- - -minishell/builtins/env/errors/001-command-not-found (FAILED) - - Description: - The purpose of this test is to check that using the builtin `env` with an invalid binary as argument results in an error and failure exit status. - - Before test: - 01: rm -f "./invalid_binary" - - STDIN: - 01: env ./invalid_binary - - STDOUT: - (no output) - - STDERR: - SUCCESS expected_to_not be_empty - WARNING might match_regex `[Cc]ommand not found` - 01: ../../42sh: env: ./invalid_binary: No such file or directory - - MISC: - FAILURE expected_to_not exit_with_status `0` - ----------------------------------------------------------------- - -minishell/builtins/exit/errors/001-too-many-args (FAILED) - - Description: - The purpose of this test is to check that using a wrong number of arguments with the builtin `exit` does not result in the Shell termination but an error on standard error. - - STDIN: - 01: exit 21 42 - 02: ./write_on_stdout TOKEN201703242314 - - STDOUT: - FAILURE expected_to match_regex `TOKEN201703242314` - (no output) - - STDERR: - FAILURE expected_to_not be_empty - WARNING might match_regex `([Tt]oo many arguments|[Aa]rgument list too long)` - (no output) - - MISC: - FAILURE expected_to exit_with_status `0` - -Total tests: 54 -Total failed tests: 6 -Total pending tests: 0 diff --git a/42sh/other b/42sh/other deleted file mode 100644 index 15118256..00000000 --- a/42sh/other +++ /dev/null @@ -1 +0,0 @@ -cat: stdout: Bad file descriptor diff --git a/42sh/test.c b/42sh/test.c deleted file mode 100644 index 2adb839e..00000000 --- a/42sh/test.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "stdio.h" -#include "string.h" - -int main(void) -{ - char str[10]; - - strcpy(str, "aaaaaaaaaaaaaaaaaaaaaaaa"); - return (0); -} diff --git a/42sh/test.sh b/42sh/test.sh deleted file mode 100644 index 0e9b1b95..00000000 --- a/42sh/test.sh +++ /dev/null @@ -1 +0,0 @@ -ls | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e diff --git a/42sh/test1 b/42sh/test1 deleted file mode 100644 index 23313b66..00000000 --- a/42sh/test1 +++ /dev/null @@ -1,24 +0,0 @@ -42ShellTester -42sh -Makefile -README.md -STDBUG -auteur -donovan_segaults_06-02 -file -file1 -includes -libft -minishell_error -objs -other -pdf -sample -scriptheader.sh -src -test -test.c -test.sh -test1 -update_makefile.sh -/Users/ariard/Projects/42sh From 6d742b1235254bf8b24e5ebc96b9d42f11d8026d Mon Sep 17 00:00:00 2001 From: M600 Date: Mon, 27 Mar 2017 09:31:31 +0200 Subject: [PATCH 04/18] Completion: Add Shift+Tab to move back in the list like zsh --- 42sh/includes/completion.h | 4 +++- 42sh/src/completion/completion.c | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/42sh/includes/completion.h b/42sh/includes/completion.h index 935a279a..dcd66200 100644 --- a/42sh/includes/completion.h +++ b/42sh/includes/completion.h @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/02/18 11:13:04 by alao #+# #+# */ -/* Updated: 2017/03/23 15:41:32 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 09:30:01 by alao ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,8 @@ # define KP_D 4348699 # define KP_L 4479771 # define KP_R 4414235 +# define KP_T 9 +# define KP_TS 5921563 /* ** Autocompletion list for the valid candidates from the parser. diff --git a/42sh/src/completion/completion.c b/42sh/src/completion/completion.c index 2a5f7afb..752ed3f5 100644 --- a/42sh/src/completion/completion.c +++ b/42sh/src/completion/completion.c @@ -6,18 +6,18 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/09/20 14:50:33 by alao #+# #+# */ -/* Updated: 2017/03/23 18:58:47 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 09:30:40 by alao ### ########.fr */ /* */ /* ************************************************************************** */ #include "completion.h" /* -** Function to select the next item in the list if it has already been created -** and if the key pressed is tab. +** Function to select the next or previous item in the list if it has already +** been created and if the key pressed is tab. */ -static void c_next_item(t_comp *c) +static void c_mv_tab(t_comp *c, int next) { t_clst *ptr; @@ -25,8 +25,11 @@ static void c_next_item(t_comp *c) while (!ptr->cursor) ptr = ptr->next; ptr->cursor = 0; - ptr->next->cursor = 1; -} + if (next) + ptr->next->cursor = 1; + else + ptr->prev->cursor = 1; + } /* ** Once the completion has been processed, this is the return point. @@ -117,8 +120,8 @@ int completion(long int keypress) else { c_term_resize(s->comp); - if (keypress == TOUCHE_TAB) - c_next_item(s->comp); + if (keypress == KP_T || keypress == KP_TS) + keypress == KP_T ? c_mv_tab(s->comp, 1) : c_mv_tab(s->comp, 0); else if (c_keypress(s->comp, keypress)) return (1); } From f3aa0ec09673d85d0b5b5a4df0da2fe39d08a8ba Mon Sep 17 00:00:00 2001 From: Gautier Wojda Date: Mon, 27 Mar 2017 11:27:43 +0200 Subject: [PATCH 05/18] close prompt mal place --- 42sh/src/line_editing/ft_prompt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/42sh/src/line_editing/ft_prompt.c b/42sh/src/line_editing/ft_prompt.c index 3f12ed95..61a355a9 100644 --- a/42sh/src/line_editing/ft_prompt.c +++ b/42sh/src/line_editing/ft_prompt.c @@ -19,7 +19,6 @@ static int promt_git_status(int fd) char *line; get_next_line(fd, &line); - close(fd); tmp = line; if (ft_strrchr(line, '/')) line = ft_strdup(ft_strrchr(line, '/') + 1); @@ -36,6 +35,7 @@ static int promt_git_status(int fd) ft_strdel(&tmp); while (get_next_line(fd, &tmp) > 0) ft_strdel(&tmp); + close(fd); ft_strdel(&tmp); return (len + 8); } From 1d4aff4746fb2aaa52021819098864afbed89e05 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 27 Mar 2017 15:10:57 +0200 Subject: [PATCH 06/18] case good close #212 #208 --- 42sh/Makefile | 4 ++-- 42sh/src/exec/exec_case_branch.c | 3 ++- 42sh/src/exec/plaunch_case.c | 4 +--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/42sh/Makefile b/42sh/Makefile index 4caa3e26..c81ce63e 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,14 +6,14 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -# Updated: 2017/03/27 03:12:30 by ariard ### ########.fr # +# Updated: 2017/03/27 15:09:22 by ariard ### ########.fr # # # # **************************************************************************** # NAME = 42sh CC = gcc -FLAGS = -Wall -Wextra -Werror #-fsanitize=address +FLAGS = -Wall -Wextra -Werror -fsanitize=address D_FLAGS = -g DELTA = $$(echo "$$(tput cols)-47"|bc) diff --git a/42sh/src/exec/exec_case_branch.c b/42sh/src/exec/exec_case_branch.c index 91fa3e1e..84dc6208 100644 --- a/42sh/src/exec/exec_case_branch.c +++ b/42sh/src/exec/exec_case_branch.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 20:33:45 by wescande #+# #+# */ -/* Updated: 2017/03/22 22:10:26 by ariard ### ########.fr */ +/* Updated: 2017/03/27 15:05:49 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,6 +26,7 @@ int exec_case_branch(t_btree **ast) if (av && (ft_strcmp(av[0], ((char **)exec->case_pattern)[0]) == 0)) { exec->attrs |= EXEC_CASE_BRANCH; + ft_tabdel(&exec->case_pattern); ft_exec(&(*ast)->right); } ft_tabdel(&av); diff --git a/42sh/src/exec/plaunch_case.c b/42sh/src/exec/plaunch_case.c index 3d3692ca..6c96e76e 100644 --- a/42sh/src/exec/plaunch_case.c +++ b/42sh/src/exec/plaunch_case.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 19:02:23 by wescande #+# #+# */ -/* Updated: 2017/03/27 03:47:36 by ariard ### ########.fr */ +/* Updated: 2017/03/27 15:06:42 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,8 +18,6 @@ int plaunch_case(t_process *p) exec = &data_singleton()->exec; exec->attrs &= ~EXEC_CASE_BRANCH; - if (exec->case_pattern && *exec->case_pattern) - ft_tabdel(&exec->case_pattern); exec->case_pattern = token_to_argv(p->data.d_case.token, 1); ft_exec(&p->data.d_case.content); ft_tabdel(&exec->case_pattern); From f17e232003d9f54edcf73ba3027a7d1558be8b3b Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 16:05:38 +0200 Subject: [PATCH 07/18] init/destroy methods for shell_fds and jobc. (#210, #214) --- 42sh/Makefile | 6 +- 42sh/includes/exec.h | 5 +- 42sh/includes/job_control.h | 3 +- 42sh/includes/minishell.h | 13 ++- 42sh/src/builtin/is_builtin.c | 2 +- 42sh/src/exec/exec_destroy.c | 6 +- 42sh/src/exec/exec_init.c | 12 +-- 42sh/src/exec/exec_pushfds.c | 29 ------- 42sh/src/exec/plaunch_builtin.c | 2 +- 42sh/src/exec/plaunch_file.c | 4 +- 42sh/src/exec/process_launch.c | 20 +++-- 42sh/src/job_control/do_job_notification.c | 2 +- 42sh/src/job_control/jobc_destroy.c | 2 +- .../exec_popfds.c => job_control/jobc_init.c} | 22 ++--- 42sh/src/main/data_exit.c | 7 +- 42sh/src/main/data_init.c | 3 +- 42sh/src/main/main.c | 2 +- 42sh/src/main/shell_fds.c | 84 +++++++++++++++++++ 42sh/src/main/shell_init.c | 5 +- 42sh/src/main/{shell_reset.c => shell_sig.c} | 24 +----- 20 files changed, 142 insertions(+), 111 deletions(-) delete mode 100644 42sh/src/exec/exec_pushfds.c rename 42sh/src/{exec/exec_popfds.c => job_control/jobc_init.c} (66%) create mode 100644 42sh/src/main/shell_fds.c rename 42sh/src/main/{shell_reset.c => shell_sig.c} (68%) diff --git a/42sh/Makefile b/42sh/Makefile index 4caa3e26..3b588045 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -78,8 +78,6 @@ exec/exec_init.c\ exec/exec_leaf.c\ exec/exec_or_if.c\ exec/exec_pipe.c\ -exec/exec_popfds.c\ -exec/exec_pushfds.c\ exec/exec_semi.c\ exec/exec_var.c\ exec/fd_is_valid.c\ @@ -197,6 +195,7 @@ job_control/job_update_id.c\ job_control/job_update_status.c\ job_control/job_wait.c\ job_control/jobc_destroy.c\ +job_control/jobc_init.c\ job_control/mark_job_as_running.c\ job_control/pprint_brace.c\ job_control/pprint_case.c\ @@ -286,8 +285,9 @@ main/data_init.c\ main/data_singleton.c\ main/ft_putast.c\ main/main.c\ +main/shell_fds.c\ main/shell_init.c\ -main/shell_reset.c\ +main/shell_sig.c\ parser/add_bang.c\ parser/add_case.c\ parser/add_cmd.c\ diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index c2445149..ce602f64 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2017/03/26 21:39:33 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 15:46:34 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -131,7 +131,6 @@ struct s_job struct s_exec { t_job job; - t_list *fd_save[10]; t_flag attrs; int fdin; t_list *op_stack; @@ -141,8 +140,6 @@ struct s_exec int exec_init(t_exec *exec); int exec_destroy(t_exec *exec); -int exec_pushfds(); -int exec_popfds(); int process_fork(t_process *p); int process_setgroup(t_process *p, pid_t pid); void process_setsig(void); diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index 6d9a8b19..26262861 100644 --- a/42sh/includes/job_control.h +++ b/42sh/includes/job_control.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */ -/* Updated: 2017/03/27 03:11:08 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:01:12 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,6 +35,7 @@ struct s_jobc struct termios shell_tmodes; }; +int jobc_init(t_jobc *jobc); int jobc_destroy(t_jobc *jobc); t_list *job_getprocess(pid_t pid); diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index 2488f600..0b755490 100644 --- a/42sh/includes/minishell.h +++ b/42sh/includes/minishell.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ -/* Updated: 2017/03/25 15:44:08 by ariard ### ########.fr */ +/* Updated: 2017/03/27 15:55:04 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -48,6 +48,7 @@ struct s_data char **argv; t_line line; t_lexer lexer; + t_list *fd_save[10]; t_parser parser; t_comp *comp; t_exec exec; @@ -64,8 +65,14 @@ int data_init(int ac, char **av, char **env); void data_exit(void); int get_c_arg(char *opt_arg, t_data *data); -void shell_resetfds(void); -void shell_resetsig(void); +void shell_sig_reset(void); + +void shell_fds_init(void); +void shell_fds_destroy(void); +int shell_fds_pop(void); +int shell_fds_push(void); +void shell_fds_reset(void); +void shell_fds_destroy(void); char *ft_putast(void *node); void ft_putast2(void *node); diff --git a/42sh/src/builtin/is_builtin.c b/42sh/src/builtin/is_builtin.c index 0798eb5a..65a87bcc 100644 --- a/42sh/src/builtin/is_builtin.c +++ b/42sh/src/builtin/is_builtin.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */ -/* Updated: 2017/03/25 16:36:55 by ariard ### ########.fr */ +/* Updated: 2017/03/27 16:03:10 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_destroy.c b/42sh/src/exec/exec_destroy.c index f1d7c764..c01bae48 100644 --- a/42sh/src/exec/exec_destroy.c +++ b/42sh/src/exec/exec_destroy.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/27 03:09:58 by jhalford #+# #+# */ -/* Updated: 2017/03/27 03:10:37 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 15:56:47 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,9 @@ int exec_destroy(t_exec *exec) { if (!exec) - return (0); + return (1); ft_lstdel(&exec->op_stack, ft_lst_cfree); + exec->attrs = 0; + exec->fdin = STDIN; return (0); } diff --git a/42sh/src/exec/exec_init.c b/42sh/src/exec/exec_init.c index 4bcae2d2..d8b840b8 100644 --- a/42sh/src/exec/exec_init.c +++ b/42sh/src/exec/exec_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/26 21:28:09 by jhalford #+# #+# */ -/* Updated: 2017/03/26 22:13:04 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 15:57:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,19 +24,9 @@ int job_init(t_job *job) int exec_init(t_exec *exec) { - t_jobc *jobc; - int i; - - jobc = &data_singleton()->jobc; job_init(&exec->job); - i = -1; - while (++i < 10) - exec->fd_save[i] = NULL; - exec_pushfds(); exec->attrs = 0; exec->fdin = STDIN; exec->op_stack = NULL; - jobc->first_job = NULL; - jobc->current_id = 1; return (0); } diff --git a/42sh/src/exec/exec_pushfds.c b/42sh/src/exec/exec_pushfds.c deleted file mode 100644 index 31c16cde..00000000 --- a/42sh/src/exec/exec_pushfds.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* exec_pushfds.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/26 21:31:46 by jhalford #+# #+# */ -/* Updated: 2017/03/27 00:58:25 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -int exec_pushfds(void) -{ - int i; - int fd; - t_exec *exec; - - exec = &data_singleton()->exec; - i = -1; - while (++i < 10) - { - fd = fcntl(i, F_DUPFD_CLOEXEC, 10); - push(&(exec->fd_save[i]), fd); - } - return (0); -} diff --git a/42sh/src/exec/plaunch_builtin.c b/42sh/src/exec/plaunch_builtin.c index 93960d1a..1efa4ae8 100644 --- a/42sh/src/exec/plaunch_builtin.c +++ b/42sh/src/exec/plaunch_builtin.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */ -/* Updated: 2017/03/24 14:56:11 by wescande ### ########.fr */ +/* Updated: 2017/03/27 16:03:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/plaunch_file.c b/42sh/src/exec/plaunch_file.c index a9e66228..0c66bee9 100644 --- a/42sh/src/exec/plaunch_file.c +++ b/42sh/src/exec/plaunch_file.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */ -/* Updated: 2017/03/22 21:32:36 by wescande ### ########.fr */ +/* Updated: 2017/03/27 16:02:52 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,7 +28,7 @@ int plaunch_file(t_process *p) error_launch(p->data.cmd.av[0], ": is a directory", 126); else if (access(p->data.cmd.path, X_OK) == -1) error_launch("permission denied: ", p->data.cmd.av[0], 126); - (*p->data.cmd.execf)( + execve( p->data.cmd.path, p->data.cmd.av, data_singleton()->env); diff --git a/42sh/src/exec/process_launch.c b/42sh/src/exec/process_launch.c index bde46f83..ad08a3b9 100644 --- a/42sh/src/exec/process_launch.c +++ b/42sh/src/exec/process_launch.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */ -/* Updated: 2017/03/27 01:01:27 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:04:22 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,10 +27,16 @@ int process_fork(t_process *p) process_setgroup(p, 0); process_setsig(); exec_destroy(&data_singleton()->exec); - exec_init(&data_singleton()->exec); + jobc_destroy(&data_singleton()->jobc); + if (p->type == PROCESS_FILE) + shell_fds_destroy(); + else + shell_fds_push(); data_singleton()->opts &= ~SH_INTERACTIVE; data_singleton()->opts &= ~SH_OPTS_JOBC; - exit(p->map.launch(p)); + pid = p->map.launch(p); + shell_fds_destroy(); + exit(pid); } int process_launch(t_process *p) @@ -52,12 +58,12 @@ int process_launch(t_process *p) set_exitstatus(1, 1); else { - exec_pushfds(); + shell_fds_push(); p->map.launch(p); - exec_popfds(); - shell_resetfds(); - shell_resetsig(); + shell_fds_pop(); } + shell_fds_reset(); + shell_sig_reset(); process_free(p, 0); return (0); } diff --git a/42sh/src/job_control/do_job_notification.c b/42sh/src/job_control/do_job_notification.c index b9536e8a..4fa661df 100644 --- a/42sh/src/job_control/do_job_notification.c +++ b/42sh/src/job_control/do_job_notification.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */ -/* Updated: 2017/03/21 14:14:45 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 15:58:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/jobc_destroy.c b/42sh/src/job_control/jobc_destroy.c index 2f86df98..068d1238 100644 --- a/42sh/src/job_control/jobc_destroy.c +++ b/42sh/src/job_control/jobc_destroy.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/27 03:09:41 by jhalford #+# #+# */ -/* Updated: 2017/03/27 03:10:55 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 15:59:29 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_popfds.c b/42sh/src/job_control/jobc_init.c similarity index 66% rename from 42sh/src/exec/exec_popfds.c rename to 42sh/src/job_control/jobc_init.c index d4fc942e..fd8fc134 100644 --- a/42sh/src/exec/exec_popfds.c +++ b/42sh/src/job_control/jobc_init.c @@ -1,30 +1,20 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* exec_popfds.c :+: :+: :+: */ +/* jobc_init.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/26 21:31:05 by jhalford #+# #+# */ -/* Updated: 2017/03/27 00:58:34 by jhalford ### ########.fr */ +/* Created: 2017/03/27 15:59:03 by jhalford #+# #+# */ +/* Updated: 2017/03/27 16:01:41 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -int exec_popfds(void) +int jobc_init(t_jobc *jobc) { - int i; - int fd; - t_exec *exec; - - exec = &data_singleton()->exec; - i = -1; - while (++i < 10) - { - fd = pop(&exec->fd_save[i]); - if (fd != -1) - close(fd); - } + jobc->first_job = NULL; + jobc->current_id = 1; return (0); } diff --git a/42sh/src/main/data_exit.c b/42sh/src/main/data_exit.c index 11ca50b9..bea98b57 100644 --- a/42sh/src/main/data_exit.c +++ b/42sh/src/main/data_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */ -/* Updated: 2017/03/27 03:11:57 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:04:32 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,6 @@ void data_exit(void) { t_data *data; - int i; data = data_singleton(); /* ft_strdel(&data->line.input); */ @@ -27,9 +26,7 @@ void data_exit(void) parser_destroy(&data->parser); exec_destroy(&data->exec); jobc_destroy(&data->jobc); - i = -1; - while (++i < 10) - ft_lstdel(&data->exec.fd_save[i], ft_lst_cfree); + shell_fds_destroy(); ft_lstdel(&data->lst_func, &tree_func_free); ft_save_termios(-1); ft_free_hash_table(); diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index a554d48f..85205e8c 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/03/26 21:54:19 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:00:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -86,6 +86,7 @@ int data_init(int ac, char **av, char **env) lexer_init(&data->lexer); parser_init(&data->parser); exec_init(&data->exec); + jobc_init(&data->jobc); if ((term_name = ft_getenv(data->env, "TERM")) == NULL) term_name = "dumb"; if (tgetent(NULL, term_name) != 1) diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 73156a39..f77f4c60 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ -/* Updated: 2017/03/26 21:57:37 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 15:58:12 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/shell_fds.c b/42sh/src/main/shell_fds.c new file mode 100644 index 00000000..8761e728 --- /dev/null +++ b/42sh/src/main/shell_fds.c @@ -0,0 +1,84 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* shell_fds.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/27 15:32:13 by jhalford #+# #+# */ +/* Updated: 2017/03/27 15:57:21 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +void shell_fds_init(void) +{ + t_data *data; + int i; + + data = data_singleton(); + i = -1; + while (++i < 10) + data->fd_save[i] = NULL; +} + +int shell_fds_push(void) +{ + t_data *data; + int i; + int fd; + + data = data_singleton(); + i = -1; + while (++i < 10) + { + fd = fcntl(i, F_DUPFD_CLOEXEC, 10); + push(&(data->fd_save[i]), fd); + } + return (0); +} + +int shell_fds_pop(void) +{ + t_data *data; + int i; + int fd; + + data = data_singleton(); + i = -1; + while (++i < 10) + { + fd = pop(&data->fd_save[i]); + if (fd != -1) + close(fd); + } + return (0); +} + +void shell_fds_reset(void) +{ + t_data *data; + int i; + int fd; + + data = data_singleton(); + i = -1; + while (++i < 10) + { + fd = top(data->fd_save[i]); + if (fd != -1) + dup2(fd, i); + } +} + +void shell_fds_destroy(void) +{ + t_data *data; + int i; + + data = data_singleton(); + i = -1; + while (++i < 10) + ft_lstdel(&data->fd_save[i], ft_lst_cfree); +} diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index ec68356f..5397a51c 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:41:36 by wescande ### ########.fr */ +/* Updated: 2017/03/27 16:04:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -70,7 +70,7 @@ static int interactive_settings(void) while (tcgetpgrp(STDIN) != (*shell_pgid = getpgrp())) kill(-*shell_pgid, SIGTTIN); *shell_pgid = getpid(); - shell_resetsig(); + shell_sig_reset(); if (setpgid(*shell_pgid, *shell_pgid)) { SH_ERR("setpgid(): %s", strerror(errno)); @@ -99,5 +99,6 @@ int shell_init(int ac, char **av, char **env) return (-1); if (SH_IS_INTERACTIVE(data->opts) && interactive_settings() < 0) return (-1); + shell_fds_init(); return (0); } diff --git a/42sh/src/main/shell_reset.c b/42sh/src/main/shell_sig.c similarity index 68% rename from 42sh/src/main/shell_reset.c rename to 42sh/src/main/shell_sig.c index dca33bfd..01ced561 100644 --- a/42sh/src/main/shell_reset.c +++ b/42sh/src/main/shell_sig.c @@ -1,18 +1,18 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* shell_reset.c :+: :+: :+: */ +/* shell_sig_reset.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/22 16:07:14 by jhalford #+# #+# */ -/* Updated: 2017/03/24 20:09:29 by jhalford ### ########.fr */ +/* Created: 2017/03/27 15:35:01 by jhalford #+# #+# */ +/* Updated: 2017/03/27 15:35:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -void shell_resetsig(void) +void shell_sig_reset(void) { signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); @@ -21,19 +21,3 @@ void shell_resetsig(void) signal(SIGTTOU, SIG_IGN); signal(SIGCHLD, SIG_DFL); } - -void shell_resetfds(void) -{ - t_exec *exec; - int i; - int fd; - - exec = &data_singleton()->exec; - i = -1; - while (++i < 10) - { - fd = top(exec->fd_save[i]); - if (fd != -1) - dup2(fd, i); - } -} From 6b67ceb22416753e5872be46dcdc75ab238e18ac Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 16:47:08 +0200 Subject: [PATCH 08/18] process_launch refactor --- 42sh/Makefile | 4 ++-- 42sh/src/exec/plaunch_file.c | 6 +++--- 42sh/src/exec/process_launch.c | 25 +++++++++++-------------- 42sh/src/exec/redirect_great.c | 4 ++-- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/42sh/Makefile b/42sh/Makefile index 91ecaa0b..b39cae83 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,14 +6,14 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -# Updated: 2017/03/27 15:09:22 by ariard ### ########.fr # +# Updated: 2017/03/27 16:09:37 by jhalford ### ########.fr # # # # **************************************************************************** # NAME = 42sh CC = gcc -FLAGS = -Wall -Wextra -Werror -fsanitize=address +FLAGS = -Wall -Wextra -Werror #-fsanitize=address D_FLAGS = -g DELTA = $$(echo "$$(tput cols)-47"|bc) diff --git a/42sh/src/exec/plaunch_file.c b/42sh/src/exec/plaunch_file.c index 0c66bee9..474bb30d 100644 --- a/42sh/src/exec/plaunch_file.c +++ b/42sh/src/exec/plaunch_file.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */ -/* Updated: 2017/03/27 16:02:52 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:46:06 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,8 +28,8 @@ int plaunch_file(t_process *p) error_launch(p->data.cmd.av[0], ": is a directory", 126); else if (access(p->data.cmd.path, X_OK) == -1) error_launch("permission denied: ", p->data.cmd.av[0], 126); - execve( - p->data.cmd.path, + shell_fds_destroy(); + execve(p->data.cmd.path, p->data.cmd.av, data_singleton()->env); error_launch("internal execve error on ", p->data.cmd.av[0], 42); diff --git a/42sh/src/exec/process_launch.c b/42sh/src/exec/process_launch.c index ad08a3b9..9e82b20b 100644 --- a/42sh/src/exec/process_launch.c +++ b/42sh/src/exec/process_launch.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */ -/* Updated: 2017/03/27 16:04:22 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:46:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,25 +16,22 @@ int process_fork(t_process *p) { pid_t pid; + if (!p) + return (0); if ((pid = fork()) == -1) exit(SH_ERR("fork(): %s", strerror(errno))); - else if (pid) + else if (pid != 0) return (pid); - if (!p) - return (pid); - if (process_redirect(p)) - exit(1); - process_setgroup(p, 0); - process_setsig(); exec_destroy(&data_singleton()->exec); jobc_destroy(&data_singleton()->jobc); - if (p->type == PROCESS_FILE) - shell_fds_destroy(); - else + if ((pid = 1) && process_redirect(p) == 0) + { shell_fds_push(); - data_singleton()->opts &= ~SH_INTERACTIVE; - data_singleton()->opts &= ~SH_OPTS_JOBC; - pid = p->map.launch(p); + process_setgroup(p, 0); + process_setsig(); + data_singleton()->opts &= ~(SH_INTERACTIVE | SH_OPTS_JOBC); + pid = p->map.launch(p); + } shell_fds_destroy(); exit(pid); } diff --git a/42sh/src/exec/redirect_great.c b/42sh/src/exec/redirect_great.c index bea4de8d..1ea9124d 100644 --- a/42sh/src/exec/redirect_great.c +++ b/42sh/src/exec/redirect_great.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:03:53 by jhalford #+# #+# */ -/* Updated: 2017/03/26 22:36:20 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:40:05 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ int redirect_great(t_redir *redir) if ((try_access(redir->word, 0, W_OK))) return (ft_perror(NULL)); if ((fdold = open(redir->word, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) - exit (1); + exit(1); fd_replace(fdold, fdnew); return (0); } From 2e49e0c302791c5c4a1d740464be6108721f46aa Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 16:59:20 +0200 Subject: [PATCH 09/18] :umbrella: c'est bueno les enfants --- 42sh/libft/src/sys/is_directory.c | 5 +++-- 42sh/libft/src/sys/try_access.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/42sh/libft/src/sys/is_directory.c b/42sh/libft/src/sys/is_directory.c index accd92a4..98ca4bad 100644 --- a/42sh/libft/src/sys/is_directory.c +++ b/42sh/libft/src/sys/is_directory.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/25 01:40:31 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:42:02 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:58:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ int is_directory(const char *path) { struct stat path_stat; - stat(path, &path_stat); + if (stat(path, &path_stat) != 0) + return (0); return (S_ISDIR(path_stat.st_mode)); } diff --git a/42sh/libft/src/sys/try_access.c b/42sh/libft/src/sys/try_access.c index 79335cd4..3a48ac35 100644 --- a/42sh/libft/src/sys/try_access.c +++ b/42sh/libft/src/sys/try_access.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/25 01:10:56 by jhalford #+# #+# */ -/* Updated: 2017/03/26 22:36:13 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 16:58:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,10 +15,10 @@ int try_access(char *file, int exists, t_flag a_flag) { if (exists && access(file, F_OK) != 0) - return (ERR_SET(E_SYS_NOFILE, file) * 0 - 1); + return (ERR_SET(E_SYS_NOFILE, file)); else if (is_directory(file)) - return (ERR_SET(E_SYS_ISDIR, file) * 0 - 1); + return (ERR_SET(E_SYS_ISDIR, file)); else if (access(file, F_OK) == 0 && access(file, a_flag) != 0) - return (ERR_SET(E_SYS_NOPERM, file) * 0 - 1); + return (ERR_SET(E_SYS_NOPERM, file)); return (0); } From de1479f2a1f577fff4761b9877eb36320046a387 Mon Sep 17 00:00:00 2001 From: gwojda Date: Mon, 27 Mar 2017 17:01:35 +0200 Subject: [PATCH 10/18] fix decalage copy sur multiligne avec \n --- 42sh/src/line_editing/copy_cut_paste/copy_cut_paste.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/42sh/src/line_editing/copy_cut_paste/copy_cut_paste.c b/42sh/src/line_editing/copy_cut_paste/copy_cut_paste.c index cec171fb..6fb8f6c2 100644 --- a/42sh/src/line_editing/copy_cut_paste/copy_cut_paste.c +++ b/42sh/src/line_editing/copy_cut_paste/copy_cut_paste.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */ -/* Updated: 2017/03/24 11:57:45 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 16:59:59 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -104,7 +104,7 @@ int ft_v(char **str, size_t *pos) } ft_current_str(*str, *pos); ft_get_next_str(*str, pos); - ft_putnc('\b', *pos - tmp_pos); + ft_putnc('\b', *pos - tmp_pos + (((*str)[*pos]) ? 1 : 0)); *pos = tmp_pos; return (0); } From ef381ddaae66888599314f0b59f7fb74d075fc17 Mon Sep 17 00:00:00 2001 From: gwojda Date: Mon, 27 Mar 2017 18:01:25 +0200 Subject: [PATCH 11/18] bang --- 42sh/Makefile | 2 +- 42sh/includes/completion.h | 3 ++- 42sh/includes/ft_readline.h | 3 ++- 42sh/libft/includes/cliopts.h | 19 +++++++++++-------- 42sh/libft/src/lst/ft_lst_delif.c | 4 ++-- 42sh/src/builtin/builtin_cd.c | 4 ++-- 42sh/src/completion/c_match.c | 4 ++-- 42sh/src/completion/completion.c | 4 ++-- 42sh/src/exec/redirect_dgreat.c | 5 ++--- 42sh/src/exec/redirect_less.c | 6 +++--- 42sh/src/history/history_parsing.c | 5 ++--- 42sh/src/history/history_parsing_toolz.c | 9 ++++++++- .../line_editing/init_line/init_termcaps.c | 2 +- 42sh/src/line_editing/readline.c | 3 ++- 42sh/src/main/shell_init.c | 2 +- 15 files changed, 43 insertions(+), 32 deletions(-) diff --git a/42sh/Makefile b/42sh/Makefile index b39cae83..ed8d6f20 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,7 +6,7 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -# Updated: 2017/03/27 16:09:37 by jhalford ### ########.fr # +# Updated: 2017/03/27 17:02:38 by gwojda ### ########.fr # # # # **************************************************************************** # diff --git a/42sh/includes/completion.h b/42sh/includes/completion.h index dcd66200..c2ac1d27 100644 --- a/42sh/includes/completion.h +++ b/42sh/includes/completion.h @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/02/18 11:13:04 by alao #+# #+# */ -/* Updated: 2017/03/27 09:30:01 by alao ### ########.fr */ +/* Updated: 2017/03/27 17:42:17 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -189,5 +189,6 @@ int ft_sstrlen(char **s); char *ft_sstrtostr(char **s, char *sep); char *ft_add_escape(char *str, char to_escape); void c_lst_id(t_comp *c); +char *c_strdupi(char *s, int (*f)(char)); #endif diff --git a/42sh/includes/ft_readline.h b/42sh/includes/ft_readline.h index e4412ffc..f08d88b2 100644 --- a/42sh/includes/ft_readline.h +++ b/42sh/includes/ft_readline.h @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */ -/* Updated: 2017/03/23 16:16:57 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:00:07 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -134,6 +134,7 @@ int ft_nb_of_line(char *str, size_t pos); int ft_get_size_prev(char *str, size_t pos); void sigwinch_resize(int sig); size_t ft_hist_len(void); +int hist_is_delim(char c); int underline_right(char **str, size_t *pos, size_t pos_ref); int underline_left(char **str, size_t *pos, size_t pos_ref); diff --git a/42sh/libft/includes/cliopts.h b/42sh/libft/includes/cliopts.h index 9ea82890..3d7f752d 100644 --- a/42sh/libft/includes/cliopts.h +++ b/42sh/libft/includes/cliopts.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* cliopts.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 20:22:56 by jhalford #+# #+# */ -/* Updated: 2017/03/25 14:59:53 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 17:17:05 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ typedef struct s_cliopts t_cliopts; typedef struct s_data_template t_data_template; typedef long long t_flag; -struct s_cliopts +struct s_cliopts { char c; char *str; @@ -30,15 +30,18 @@ struct s_cliopts int arg_required:1; }; -struct s_data_template +struct s_data_template { t_flag flag; char **av_data; }; -int cliopts_get(char **av, t_cliopts opt_map[], void *data); -t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], char *arg); -t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], char arg); -int cliopts_has(char **av, char c); +int cliopts_get(char **av, t_cliopts opt_map[], + void *data); +t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], + char *arg); +t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], + char arg); +int cliopts_has(char **av, char c); #endif diff --git a/42sh/libft/src/lst/ft_lst_delif.c b/42sh/libft/src/lst/ft_lst_delif.c index 7580ea7d..768272b5 100644 --- a/42sh/libft/src/lst/ft_lst_delif.c +++ b/42sh/libft/src/lst/ft_lst_delif.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ft_lst_delif.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */ -/* Updated: 2017/03/13 15:36:19 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 17:45:01 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/builtin/builtin_cd.c b/42sh/src/builtin/builtin_cd.c index af086139..d0bb0d11 100644 --- a/42sh/src/builtin/builtin_cd.c +++ b/42sh/src/builtin/builtin_cd.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/25 18:20:42 by ariard #+# #+# */ -/* Updated: 2017/03/25 21:23:11 by ariard ### ########.fr */ +/* Updated: 2017/03/27 17:11:36 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,7 +31,7 @@ static t_cliopts g_cdopts[] = {0, NULL, 0, 0, NULL, 0}, }; -int cd_file_autorisations(char *target, int flag) +int cd_file_autorisations(char *target, int flag) { (void)flag; if (access(target, F_OK)) diff --git a/42sh/src/completion/c_match.c b/42sh/src/completion/c_match.c index 77fe9600..36adb113 100644 --- a/42sh/src/completion/c_match.c +++ b/42sh/src/completion/c_match.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/10/15 13:27:14 by alao #+# #+# */ -/* Updated: 2017/03/23 19:02:28 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 17:48:25 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ static int c_is_delim(char c) return (0); } -static char *c_strdupi(char *s, int (*f)(char)) +char *c_strdupi(char *s, int (*f)(char)) { int i; char *str; diff --git a/42sh/src/completion/completion.c b/42sh/src/completion/completion.c index 752ed3f5..4d6b464d 100644 --- a/42sh/src/completion/completion.c +++ b/42sh/src/completion/completion.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/09/20 14:50:33 by alao #+# #+# */ -/* Updated: 2017/03/27 09:30:40 by alao ### ########.fr */ +/* Updated: 2017/03/27 17:11:59 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,7 +29,7 @@ static void c_mv_tab(t_comp *c, int next) ptr->next->cursor = 1; else ptr->prev->cursor = 1; - } +} /* ** Once the completion has been processed, this is the return point. diff --git a/42sh/src/exec/redirect_dgreat.c b/42sh/src/exec/redirect_dgreat.c index a2d57f1c..4f7ffb1d 100644 --- a/42sh/src/exec/redirect_dgreat.c +++ b/42sh/src/exec/redirect_dgreat.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */ -/* Updated: 2017/03/26 22:36:18 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 17:09:31 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,8 +22,7 @@ int redirect_dgreat(t_redir *redir) if ((try_access(redir->word, 0, W_OK))) return (ft_perror(NULL)); if ((fdold = open(redir->word, O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0) - exit (1); - + exit(1); fd_replace(fdold, fdnew); return (0); } diff --git a/42sh/src/exec/redirect_less.c b/42sh/src/exec/redirect_less.c index 0e24b2c7..793028f7 100644 --- a/42sh/src/exec/redirect_less.c +++ b/42sh/src/exec/redirect_less.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* redirect_less.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */ -/* Updated: 2017/03/27 01:02:30 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 17:12:24 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ int redirect_less(t_redir *redir) if ((try_access(redir->word, 1, R_OK)) != 0) return (ft_perror(NULL)); if ((fdold = open(redir->word, O_RDONLY, 0644)) < 0) - exit (1); + exit(1); fd_replace(fdold, fdnew); return (0); } diff --git a/42sh/src/history/history_parsing.c b/42sh/src/history/history_parsing.c index 2c7040f3..2f1535b1 100644 --- a/42sh/src/history/history_parsing.c +++ b/42sh/src/history/history_parsing.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */ -/* Updated: 2017/03/22 12:09:59 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:00:27 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,7 +41,6 @@ static int check_validity(char *str, int i) else if (!str[i + 1] || str[i + 1] == '"') return (0); return (1); - } static int history_parsing_nb_and_name(char *str, int *i) @@ -66,7 +65,7 @@ static int history_parsing_nb_and_name(char *str, int *i) ft_strdupi_w(str + *i + 2)); else if (str[*i + 1] && str[*i + 1] != ' ') ft_realloc_str_history_2(&(data_singleton()->line.input), *i, - ft_strdupi_w(str + *i + 1)); + c_strdupi(str + *i + 1, hist_is_delim)); else return (0); return (1); diff --git a/42sh/src/history/history_parsing_toolz.c b/42sh/src/history/history_parsing_toolz.c index 4c2f00b7..3c384222 100644 --- a/42sh/src/history/history_parsing_toolz.c +++ b/42sh/src/history/history_parsing_toolz.c @@ -6,12 +6,19 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/25 14:09:39 by gwojda #+# #+# */ -/* Updated: 2017/03/16 11:58:10 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 17:59:50 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" +int hist_is_delim(char c) +{ + if (c == ' ' || c == '"') + return (1); + return (0); +} + static char *ft_nget_histo(size_t nb_his) { t_list_history *list; diff --git a/42sh/src/line_editing/init_line/init_termcaps.c b/42sh/src/line_editing/init_line/init_termcaps.c index b8b2dbdb..475bf580 100644 --- a/42sh/src/line_editing/init_line/init_termcaps.c +++ b/42sh/src/line_editing/init_line/init_termcaps.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 17:33:41 by gwojda #+# #+# */ -/* Updated: 2017/03/21 18:11:13 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 17:37:40 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line_editing/readline.c b/42sh/src/line_editing/readline.c index 82856a6f..32788265 100644 --- a/42sh/src/line_editing/readline.c +++ b/42sh/src/line_editing/readline.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ -/* Updated: 2017/03/25 18:17:57 by ariard ### ########.fr */ +/* Updated: 2017/03/27 17:38:51 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,6 +35,7 @@ int readline(int has_prompt, char **input) if (has_prompt) ret = ft_history_parsing(has_prompt, input); ft_strdel(&data_singleton()->line.copy_tmp); + DG("ret = \"%s\"", *input); if (tcsetattr(0, TCSANOW, ft_save_termios(0)) == -1) return (-1); return (ret); diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 5397a51c..b6e7181e 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/03/27 16:04:45 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 17:13:41 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ From a2545bb2e7458662a0a37a80e1ff106c78f4176f Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 18:07:20 +0200 Subject: [PATCH 12/18] norme --- 42sh/libft/includes/cliopts.h | 9 ++++----- 42sh/src/builtin/builtin_cd.c | 4 ++-- 42sh/src/completion/completion.c | 4 ++-- 42sh/src/exec/redirect_dgreat.c | 5 ++--- 42sh/src/exec/redirect_less.c | 4 ++-- 42sh/src/history/history_parsing.c | 3 +-- 42sh/src/main/data_exit.c | 3 +-- 42sh/src/main/data_init.c | 16 +++++++++++----- 42sh/src/main/shell_fds.c | 6 +++--- 42sh/src/main/shell_init.c | 10 +++++----- 10 files changed, 33 insertions(+), 31 deletions(-) diff --git a/42sh/libft/includes/cliopts.h b/42sh/libft/includes/cliopts.h index 9ea82890..60ec9ec3 100644 --- a/42sh/libft/includes/cliopts.h +++ b/42sh/libft/includes/cliopts.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 20:22:56 by jhalford #+# #+# */ -/* Updated: 2017/03/25 14:59:53 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 17:59:47 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ typedef struct s_cliopts t_cliopts; typedef struct s_data_template t_data_template; typedef long long t_flag; -struct s_cliopts +struct s_cliopts { char c; char *str; @@ -30,15 +30,14 @@ struct s_cliopts int arg_required:1; }; -struct s_data_template +struct s_data_template { t_flag flag; char **av_data; }; -int cliopts_get(char **av, t_cliopts opt_map[], void *data); +int cliopts_get(char **av, t_cliopts opt_map[], void *data); t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], char *arg); t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], char arg); -int cliopts_has(char **av, char c); #endif diff --git a/42sh/src/builtin/builtin_cd.c b/42sh/src/builtin/builtin_cd.c index af086139..99160c42 100644 --- a/42sh/src/builtin/builtin_cd.c +++ b/42sh/src/builtin/builtin_cd.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/25 18:20:42 by ariard #+# #+# */ -/* Updated: 2017/03/25 21:23:11 by ariard ### ########.fr */ +/* Updated: 2017/03/27 18:00:06 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,7 +31,7 @@ static t_cliopts g_cdopts[] = {0, NULL, 0, 0, NULL, 0}, }; -int cd_file_autorisations(char *target, int flag) +int cd_file_autorisations(char *target, int flag) { (void)flag; if (access(target, F_OK)) diff --git a/42sh/src/completion/completion.c b/42sh/src/completion/completion.c index 752ed3f5..74201f51 100644 --- a/42sh/src/completion/completion.c +++ b/42sh/src/completion/completion.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/09/20 14:50:33 by alao #+# #+# */ -/* Updated: 2017/03/27 09:30:40 by alao ### ########.fr */ +/* Updated: 2017/03/27 18:01:09 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,7 +29,7 @@ static void c_mv_tab(t_comp *c, int next) ptr->next->cursor = 1; else ptr->prev->cursor = 1; - } +} /* ** Once the completion has been processed, this is the return point. diff --git a/42sh/src/exec/redirect_dgreat.c b/42sh/src/exec/redirect_dgreat.c index a2d57f1c..62e79888 100644 --- a/42sh/src/exec/redirect_dgreat.c +++ b/42sh/src/exec/redirect_dgreat.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */ -/* Updated: 2017/03/26 22:36:18 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:00:35 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,8 +22,7 @@ int redirect_dgreat(t_redir *redir) if ((try_access(redir->word, 0, W_OK))) return (ft_perror(NULL)); if ((fdold = open(redir->word, O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0) - exit (1); - + exit(1); fd_replace(fdold, fdnew); return (0); } diff --git a/42sh/src/exec/redirect_less.c b/42sh/src/exec/redirect_less.c index 0e24b2c7..bb5cc083 100644 --- a/42sh/src/exec/redirect_less.c +++ b/42sh/src/exec/redirect_less.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */ -/* Updated: 2017/03/27 01:02:30 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:00:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ int redirect_less(t_redir *redir) if ((try_access(redir->word, 1, R_OK)) != 0) return (ft_perror(NULL)); if ((fdold = open(redir->word, O_RDONLY, 0644)) < 0) - exit (1); + exit(1); fd_replace(fdold, fdnew); return (0); } diff --git a/42sh/src/history/history_parsing.c b/42sh/src/history/history_parsing.c index 2c7040f3..45e9eba7 100644 --- a/42sh/src/history/history_parsing.c +++ b/42sh/src/history/history_parsing.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */ -/* Updated: 2017/03/22 12:09:59 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:01:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,7 +41,6 @@ static int check_validity(char *str, int i) else if (!str[i + 1] || str[i + 1] == '"') return (0); return (1); - } static int history_parsing_nb_and_name(char *str, int *i) diff --git a/42sh/src/main/data_exit.c b/42sh/src/main/data_exit.c index bea98b57..1c5a6389 100644 --- a/42sh/src/main/data_exit.c +++ b/42sh/src/main/data_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */ -/* Updated: 2017/03/27 16:04:32 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:02:20 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,6 @@ void data_exit(void) t_data *data; data = data_singleton(); - /* ft_strdel(&data->line.input); */ ft_strdel(&data->binary); ft_sstrfree(data->env); ft_sstrfree(data->local_var); diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 85205e8c..d8f7c41d 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/03/27 16:00:19 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:04:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -66,6 +66,15 @@ static int shlvl_inc(void) return (0); } +int modules_init(t_data *data) +{ + lexer_init(&data->lexer); + parser_init(&data->parser); + exec_init(&data->exec); + jobc_init(&data->jobc); + return (0); +} + int data_init(int ac, char **av, char **env) { t_data *data; @@ -80,13 +89,10 @@ int data_init(int ac, char **av, char **env) localenv_init(); if (shlvl_inc()) return (-1); + modules_init(data); data->comp = NULL; data->opts = SH_INTERACTIVE | SH_OPTS_JOBC; data->lst_func = NULL; - lexer_init(&data->lexer); - parser_init(&data->parser); - exec_init(&data->exec); - jobc_init(&data->jobc); if ((term_name = ft_getenv(data->env, "TERM")) == NULL) term_name = "dumb"; if (tgetent(NULL, term_name) != 1) diff --git a/42sh/src/main/shell_fds.c b/42sh/src/main/shell_fds.c index 8761e728..97487b80 100644 --- a/42sh/src/main/shell_fds.c +++ b/42sh/src/main/shell_fds.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/27 15:32:13 by jhalford #+# #+# */ -/* Updated: 2017/03/27 15:57:21 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:02:46 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -56,7 +56,7 @@ int shell_fds_pop(void) return (0); } -void shell_fds_reset(void) +void shell_fds_reset(void) { t_data *data; int i; @@ -72,7 +72,7 @@ void shell_fds_reset(void) } } -void shell_fds_destroy(void) +void shell_fds_destroy(void) { t_data *data; int i; diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 5397a51c..b3336442 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/03/27 16:04:45 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:06:12 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -89,10 +89,10 @@ int shell_init(int ac, char **av, char **env) if (data_init(ac, av, env) < 0) return (-1); if (cliopts_get(av, g_opts, data)) - return (ft_perror(NULL) - && SH_ERR("%s", SHELL_USAGE1) - && SH_ERR("%s", SHELL_USAGE2) - && SH_ERR("%s", SHELL_USAGE3)); + { + return (ft_perror(NULL) && SH_ERR("%s", SHELL_USAGE1) + && SH_ERR("%s", SHELL_USAGE2) && SH_ERR("%s", SHELL_USAGE3)); + } if (!isatty(STDIN) || *data->av_data) data->opts &= ~(SH_INTERACTIVE | SH_OPTS_JOBC); if ((data->fd = get_input_fd(data, NULL)) < 0) From 5c4bc19107fcdf7d3920b62a57ac8985e1970ce1 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 27 Mar 2017 18:07:24 +0200 Subject: [PATCH 13/18] sample script --- 42sh/Makefile | 4 +- 42sh/another_file | 248 +++++++++++++++++++++ 42sh/file | 20 ++ 42sh/sample/again.sh | 2 + 42sh/sample/andor.sh | 8 + 42sh/sample/brace | 1 - 42sh/sample/brace.sh | 9 + 42sh/sample/case.sh | 22 +- 42sh/sample/comment.sh | 7 + 42sh/sample/eof.sh | 3 + 42sh/sample/for.sh | 13 +- 42sh/sample/func.sh | 11 +- 42sh/sample/if.sh | 26 ++- 42sh/sample/if/02_if_elif.sh | 10 - 42sh/sample/if/03_if_else.sh | 5 - 42sh/sample/if/04_if_elseelsif.sh | 11 - 42sh/sample/infinite.sh | 2 - 42sh/sample/ls | 1 - 42sh/sample/mix.sh | 30 +++ 42sh/sample/mix/mix.sh | 21 -- 42sh/sample/muchloop.sh | 31 +++ 42sh/sample/multiredir | 3 - 42sh/sample/redir/redir.sh | 1 - 42sh/sample/script.sh | 16 ++ 42sh/sample/stack.sh | 3 - 42sh/sample/{subshell_pipe => subshell.sh} | 7 + 42sh/sample/subshell/subshell01.sh | 2 - 42sh/sample/toomuchdone.sh | 4 + 42sh/sample/until.sh | 32 ++- 42sh/sample/until/01_until.sh | 11 - 42sh/sample/until2.sh | 11 - 42sh/sample/var.sh | 11 + 42sh/sample/var_01.sh | 1 - 42sh/sample/while.sh | 28 ++- 42sh/sample/while/while01.sh | 11 - 42sh/sample/while/while02.sh | 5 - 42sh/sample/while/while03.sh | 5 - 42sh/sample/while2.sh | 16 -- 42sh/sample/while_error.sh | 6 - 42sh/sample/yale/yale0.ex | 1 - 42sh/sample/yale/yale1.ex | 1 - 42sh/sample/yale/yale2.ex | 1 - 42sh/sample/yale/yale3.ex | 1 - 42sh/sample/yale/yale5.ex | 1 - 42sh/sample/yale1.sh | 1 - 42sh/src/main/main.c | 3 +- 42sh/src/parser/aggregate_sym.c | 4 +- 42sh/src/parser/eval_sym.c | 3 +- 42sh/src/parser/produce_sym.c | 5 +- 49 files changed, 512 insertions(+), 167 deletions(-) create mode 100644 42sh/another_file create mode 100644 42sh/file create mode 100644 42sh/sample/again.sh create mode 100644 42sh/sample/andor.sh delete mode 100644 42sh/sample/brace create mode 100644 42sh/sample/brace.sh create mode 100644 42sh/sample/eof.sh delete mode 100644 42sh/sample/if/02_if_elif.sh delete mode 100644 42sh/sample/if/03_if_else.sh delete mode 100644 42sh/sample/if/04_if_elseelsif.sh delete mode 100644 42sh/sample/infinite.sh delete mode 100644 42sh/sample/ls create mode 100644 42sh/sample/mix.sh delete mode 100644 42sh/sample/mix/mix.sh create mode 100644 42sh/sample/muchloop.sh delete mode 100644 42sh/sample/multiredir delete mode 100644 42sh/sample/redir/redir.sh create mode 100644 42sh/sample/script.sh delete mode 100644 42sh/sample/stack.sh rename 42sh/sample/{subshell_pipe => subshell.sh} (84%) delete mode 100644 42sh/sample/subshell/subshell01.sh create mode 100644 42sh/sample/toomuchdone.sh delete mode 100644 42sh/sample/until/01_until.sh delete mode 100644 42sh/sample/until2.sh create mode 100644 42sh/sample/var.sh delete mode 100644 42sh/sample/var_01.sh delete mode 100644 42sh/sample/while/while01.sh delete mode 100644 42sh/sample/while/while02.sh delete mode 100644 42sh/sample/while/while03.sh delete mode 100644 42sh/sample/while2.sh delete mode 100644 42sh/sample/while_error.sh delete mode 100644 42sh/sample/yale/yale0.ex delete mode 100644 42sh/sample/yale/yale1.ex delete mode 100644 42sh/sample/yale/yale2.ex delete mode 100644 42sh/sample/yale/yale3.ex delete mode 100644 42sh/sample/yale/yale5.ex delete mode 100644 42sh/sample/yale1.sh diff --git a/42sh/Makefile b/42sh/Makefile index c81ce63e..507dca2e 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,14 +6,14 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -# Updated: 2017/03/27 15:09:22 by ariard ### ########.fr # +# Updated: 2017/03/27 15:12:02 by ariard ### ########.fr # # # # **************************************************************************** # NAME = 42sh CC = gcc -FLAGS = -Wall -Wextra -Werror -fsanitize=address +FLAGS = -Wall -Wextra -Werror #-fsanitize=address D_FLAGS = -g DELTA = $$(echo "$$(tput cols)-47"|bc) diff --git a/42sh/another_file b/42sh/another_file new file mode 100644 index 00000000..ab0fd48c --- /dev/null +++ b/42sh/another_file @@ -0,0 +1,248 @@ +hello$$ +hello$$ +bonjour$$ +salut$$ +comment$$ +src/builtin/bt_env_opt.c$$ +src/builtin/bt_read_get.c$$ +src/builtin/bt_read_term.c$$ +src/builtin/builtin_cd.c$$ +src/builtin/builtin_echo.c$$ +src/builtin/builtin_env.c$$ +src/builtin/builtin_exit.c$$ +src/builtin/builtin_export.c$$ +src/builtin/builtin_func.c$$ +src/builtin/builtin_hash.c$$ +src/builtin/builtin_history.c$$ +src/builtin/builtin_math.c$$ +src/builtin/builtin_read.c$$ +src/builtin/builtin_setenv.c$$ +src/builtin/builtin_unset.c$$ +src/builtin/builtin_unsetenv.c$$ +src/builtin/is_builtin.c$$ +src/completion/c_arrow.c$$ +src/completion/c_clear.c$$ +src/completion/c_find_abspath.c$$ +src/completion/c_find_binary.c$$ +src/completion/c_find_env.c$$ +src/completion/c_find_files.c$$ +src/completion/c_init.c$$ +src/completion/c_match.c$$ +src/completion/c_match_glob.c$$ +src/completion/c_match_update.c$$ +src/completion/c_misc.c$$ +src/completion/c_output.c$$ +src/completion/c_parser.c$$ +src/completion/c_pathsolver.c$$ +src/completion/c_printer.c$$ +src/completion/c_sizing.c$$ +src/completion/c_terminal.c$$ +src/completion/completion.c$$ +src/exec/ast_free.c$$ +src/exec/bad_fd.c$$ +src/exec/exec_ampersand.c$$ +src/exec/exec_and_if.c$$ +src/exec/exec_bang.c$$ +src/exec/exec_case_branch.c$$ +src/exec/exec_destroy.c$$ +src/exec/exec_elif.c$$ +src/exec/exec_else.c$$ +src/exec/exec_func.c$$ +src/exec/exec_init.c$$ +src/exec/exec_leaf.c$$ +src/exec/exec_or_if.c$$ +src/exec/exec_pipe.c$$ +src/exec/exec_popfds.c$$ +src/exec/exec_pushfds.c$$ +src/exec/exec_semi.c$$ +src/exec/exec_var.c$$ +src/exec/fd_is_valid.c$$ +src/exec/ft_exec.c$$ +src/exec/ft_findexec.c$$ +src/exec/is_function.c$$ +src/exec/mark_process_status.c$$ +src/exec/node_copy.c$$ +src/exec/pfree_cmd.c$$ +src/exec/pfree_cond.c$$ +src/exec/pfree_func.c$$ +src/exec/pfree_list.c$$ +src/exec/pfree_subshell.c$$ +src/exec/plaunch_brace.c$$ +src/exec/plaunch_builtin.c$$ +src/exec/plaunch_case.c$$ +src/exec/plaunch_empty.c$$ +src/exec/plaunch_file.c$$ +src/exec/plaunch_for.c$$ +src/exec/plaunch_function.c$$ +src/exec/plaunch_if.c$$ +src/exec/plaunch_subshell.c$$ +src/exec/plaunch_until.c$$ +src/exec/plaunch_while.c$$ +src/exec/process_launch.c$$ +src/exec/process_redirect.c$$ +src/exec/process_set.c$$ +src/exec/process_setgroup.c$$ +src/exec/process_setsig.c$$ +src/exec/pset_brace.c$$ +src/exec/pset_case.c$$ +src/exec/pset_cmd.c$$ +src/exec/pset_for.c$$ +src/exec/pset_if.c$$ +src/exec/pset_subshell.c$$ +src/exec/pset_until.c$$ +src/exec/pset_while.c$$ +src/exec/redir_copy.c$$ +src/exec/redir_free.c$$ +src/exec/redirect_dgreat.c$$ +src/exec/redirect_dless.c$$ +src/exec/redirect_great.c$$ +src/exec/redirect_greatand.c$$ +src/exec/redirect_less.c$$ +src/exec/redirect_lessand.c$$ +src/exec/set_exitstatus.c$$ +src/exec/token_to_argv.c$$ +src/glob/command_getoutput.c$$ +src/glob/dir_glob.c$$ +src/glob/esc_print.c$$ +src/glob/expand_bquote.c$$ +src/glob/expand_brace.c$$ +src/glob/expand_esc.c$$ +src/glob/expand_home.c$$ +src/glob/expand_var.c$$ +src/glob/ft_strsplit_esc.c$$ +src/glob/ft_strsplit_spe.c$$ +src/glob/gen_tab_esc.c$$ +src/glob/glob.c$$ +src/glob/is_char_esc.c$$ +src/glob/match_pattern.c$$ +src/glob/tab_esc_copy.c$$ +src/glob/word_is_assignment.c$$ +src/hash_table/ft_add_hash.c$$ +src/hash_table/hash.c$$ +src/hash_table/hash_free.c$$ +src/hash_table/hash_str.c$$ +src/hash_table/is_hash.c$$ +src/history/add_str_in_history.c$$ +src/history/history.c$$ +src/history/history_parsing.c$$ +src/history/history_parsing_toolz.c$$ +src/history/history_parsing_toolz_2.c$$ +src/history/list_toolz.c$$ +src/history/surch_in_history.c$$ +src/job_control/builtin_bg.c$$ +src/job_control/builtin_fg.c$$ +src/job_control/builtin_jobs.c$$ +src/job_control/do_job_notification.c$$ +src/job_control/has_running_job.c$$ +src/job_control/has_stopped_job.c$$ +src/job_control/job_addprocess.c$$ +src/job_control/job_cmp_id.c$$ +src/job_control/job_format.c$$ +src/job_control/job_format_head.c$$ +src/job_control/job_free.c$$ +src/job_control/job_getprocess.c$$ +src/job_control/job_getrank.c$$ +src/job_control/job_hup_all.c$$ +src/job_control/job_is_completed.c$$ +src/job_control/job_is_stopped.c$$ +src/job_control/job_notify_change.c$$ +src/job_control/job_notify_new.c$$ +src/job_control/job_remove.c$$ +src/job_control/job_run.c$$ +src/job_control/job_update_id.c$$ +src/job_control/job_update_status.c$$ +src/job_control/job_wait.c$$ +src/job_control/jobc_destroy.c$$ +src/job_control/mark_job_as_running.c$$ +src/job_control/pprint_brace.c$$ +src/job_control/pprint_case.c$$ +src/job_control/pprint_cmd.c$$ +src/job_control/pprint_for.c$$ +src/job_control/pprint_function.c$$ +src/job_control/pprint_if.c$$ +src/job_control/pprint_subshell.c$$ +src/job_control/pprint_until.c$$ +src/job_control/pprint_while.c$$ +src/job_control/process_cmp_pid.c$$ +src/job_control/process_format.c$$ +src/job_control/process_free.c$$ +src/job_control/put_job_in_background.c$$ +src/job_control/put_job_in_foreground.c$$ +src/job_control/sigchld_handler.c$$ +src/job_control/sigint_handler.c$$ +src/job_control/sigtstp_handler.c$$ +src/job_control/sigttin_handler.c$$ +src/job_control/sigttou_handler.c$$ +src/lexer/do_lexer_routine.c$$ +src/lexer/get_lexer_stack.c$$ +src/lexer/get_lexer_stack2.c$$ +src/lexer/get_reserved_words.c$$ +src/lexer/get_state_global.c$$ +src/lexer/get_state_redir.c$$ +src/lexer/insert_newline.c$$ +src/lexer/isrw_delim.c$$ +src/lexer/keep_last_type.c$$ +src/lexer/lexer_backslash.c$$ +src/lexer/lexer_bquote.c$$ +src/lexer/lexer_curly_braces.c$$ +src/lexer/lexer_default.c$$ +src/lexer/lexer_delim.c$$ +src/lexer/lexer_destroy.c$$ +src/lexer/lexer_dquote.c$$ +src/lexer/lexer_end.c$$ +src/lexer/lexer_great.c$$ +src/lexer/lexer_heredoc.c$$ +src/lexer/lexer_init.c$$ +src/lexer/lexer_less.c$$ +src/lexer/lexer_lex.c$$ +src/lexer/lexer_newline.c$$ +src/lexer/lexer_number.c$$ +src/lexer/lexer_paren.c$$ +src/lexer/lexer_quote.c$$ +src/lexer/lexer_sep.c$$ +src/lexer/lexer_word.c$$ +src/lexer/token_append.c$$ +src/lexer/token_cmp_type.c$$ +src/lexer/token_free.c$$ +src/lexer/token_init.c$$ +src/lexer/token_print.c$$ +src/line_editing/control_features.c$$ +src/line_editing/ft_prompt.c$$ +src/line_editing/get_key.c$$ +src/line_editing/readline.c$$ +src/line_editing/resize.c$$ +src/main/data_exit.c$$ +src/main/data_init.c$$ +src/main/data_singleton.c$$ +src/main/ft_putast.c$$ +src/main/main.c$$ +src/main/shell_init.c$$ +src/main/shell_reset.c$$ +src/parser/add_bang.c$$ +src/parser/add_case.c$$ +src/parser/add_cmd.c$$ +src/parser/add_condition.c$$ +src/parser/add_func.c$$ +src/parser/add_loop.c$$ +src/parser/add_number.c$$ +src/parser/add_redir.c$$ +src/parser/add_sep.c$$ +src/parser/add_subshell.c$$ +src/parser/aggregate_sym.c$$ +src/parser/build_tree.c$$ +src/parser/do_parser_routine.c$$ +src/parser/error_syntax.c$$ +src/parser/eval_sym.c$$ +src/parser/ft_parse.c$$ +src/parser/heredoc_parser.c$$ +src/parser/parser_destroy.c$$ +src/parser/parser_init.c$$ +src/parser/pop_stack.c$$ +src/parser/produce_sym.c$$ +src/parser/push_stack.c$$ +src/parser/read_stack.c$$ +src/parser/redir_init.c$$ +src/parser/stack_init.c$$ +src/parser/sym_free.c$$ +src/parser/tree_func_free.c$$ +src/parser/tree_wrapper.c$$ diff --git a/42sh/file b/42sh/file new file mode 100644 index 00000000..4b2174a6 --- /dev/null +++ b/42sh/file @@ -0,0 +1,20 @@ +/Users/ariard/Projects/42sh +/Users/ariard/Projects/42sh +42ShellTester +42sh +Makefile +README.md +STDBUG +another_file +auteur +donovan_segaults_06-02 +file +includes +libft +objs +pdf +sample +scriptheader.sh +src +test +update_makefile.sh diff --git a/42sh/sample/again.sh b/42sh/sample/again.sh new file mode 100644 index 00000000..1a85b88c --- /dev/null +++ b/42sh/sample/again.sh @@ -0,0 +1,2 @@ +echo "echo hello" >> sample/again.sh +echo hello diff --git a/42sh/sample/andor.sh b/42sh/sample/andor.sh new file mode 100644 index 00000000..76759a12 --- /dev/null +++ b/42sh/sample/andor.sh @@ -0,0 +1,8 @@ +pwd > file && pwd >> file || ls | cat && ls | cat >> file || ls +cat -e file + +sleep 2 +echo "My sample :" +echo +cat sample/andor.sh + diff --git a/42sh/sample/brace b/42sh/sample/brace deleted file mode 100644 index 54b84d56..00000000 --- a/42sh/sample/brace +++ /dev/null @@ -1 +0,0 @@ -{ ls | cat } diff --git a/42sh/sample/brace.sh b/42sh/sample/brace.sh new file mode 100644 index 00000000..6f0a47f3 --- /dev/null +++ b/42sh/sample/brace.sh @@ -0,0 +1,9 @@ +{ ls ; pwd } > file +cat -e file + +sleep 2 +echo +echo "My sample :" +sleep 2 +echo +cat sample/brace.sh diff --git a/42sh/sample/case.sh b/42sh/sample/case.sh index 14b13108..420f2235 100644 --- a/42sh/sample/case.sh +++ b/42sh/sample/case.sh @@ -1,8 +1,16 @@ -case van in - ( "bus" ) echo Hello world ;; - ( "velo" ) echo Comment va ;; - ( "van" ) case tutu in - ( toto ) pwd ;; - ( tutu ) ls ;; +case toto in + ( tutu ) echo PERDU ;; + ( titi ) echo PERDU ;; + ( toto ) case lala in + ( lolo ) echo PERDU ;; + ( lala ) echo GAGNE ;; esac ;; -esac +esac > file +cat -e file + +sleep 2 +echo +echo "My sample :" +sleep 2 +echo +cat sample/case.sh diff --git a/42sh/sample/comment.sh b/42sh/sample/comment.sh index 0680845f..e4d6764f 100644 --- a/42sh/sample/comment.sh +++ b/42sh/sample/comment.sh @@ -1,2 +1,9 @@ ls # Da comment pwd + +sleep 2 +echo +echo "My sample :" +sleep 2 +echo +cat sample/comment.sh diff --git a/42sh/sample/eof.sh b/42sh/sample/eof.sh new file mode 100644 index 00000000..e7c86456 --- /dev/null +++ b/42sh/sample/eof.sh @@ -0,0 +1,3 @@ +while [ 1 ] +do + ls diff --git a/42sh/sample/for.sh b/42sh/sample/for.sh index c38dab32..2d6dbe87 100644 --- a/42sh/sample/for.sh +++ b/42sh/sample/for.sh @@ -1,4 +1,13 @@ -for i in hello bonjour salut comment +for i in src/*/*.c do - echo $i | cat -e + echo $i | cat -e > file + cat -e file >> another_file + cat -e another_file done + +sleep 2 +echo +echo "My sample :" +sleep 2 +echo +cat sample/for.sh diff --git a/42sh/sample/func.sh b/42sh/sample/func.sh index fefce167..585f90a0 100644 --- a/42sh/sample/func.sh +++ b/42sh/sample/func.sh @@ -1,5 +1,14 @@ hello() ( - echo HELLO + hello() ( + echo hello ; hello ) + hello ) hello + +sleep 2 +echo +echo "My sample :" +sleep 2 +echo +cat sample/func.sh diff --git a/42sh/sample/if.sh b/42sh/sample/if.sh index 198b0a62..6364a745 100644 --- a/42sh/sample/if.sh +++ b/42sh/sample/if.sh @@ -1,9 +1,25 @@ -if cat wef4eeef +if false then - echo Conditon 1 -elif cat yulu + echo PERDU +elif false then - echo Condition 2 + echo PERDU +elif true +then + if false + then + echo PERDU + elif + echo GAGNE + fi > file else - echo Condition 3 + echo PERDU fi +cat -e file + +sleep 2 +echo +echo "My sample :" +sleep 2 +echo +cat sample/if.sh diff --git a/42sh/sample/if/02_if_elif.sh b/42sh/sample/if/02_if_elif.sh deleted file mode 100644 index ae93a37e..00000000 --- a/42sh/sample/if/02_if_elif.sh +++ /dev/null @@ -1,10 +0,0 @@ -if ls ; -then - pwd -elif ls -then - pwd -elif ls -then - pwd -fi diff --git a/42sh/sample/if/03_if_else.sh b/42sh/sample/if/03_if_else.sh deleted file mode 100644 index a02520e0..00000000 --- a/42sh/sample/if/03_if_else.sh +++ /dev/null @@ -1,5 +0,0 @@ -if cat yolo ; -then - pwd -else ls -fi diff --git a/42sh/sample/if/04_if_elseelsif.sh b/42sh/sample/if/04_if_elseelsif.sh deleted file mode 100644 index a52c07e3..00000000 --- a/42sh/sample/if/04_if_elseelsif.sh +++ /dev/null @@ -1,11 +0,0 @@ -if cat yolo ; -then - pwd -elif ls -then - pwd -elif pwd -then - ls -else ls -fi diff --git a/42sh/sample/infinite.sh b/42sh/sample/infinite.sh deleted file mode 100644 index 740015ae..00000000 --- a/42sh/sample/infinite.sh +++ /dev/null @@ -1,2 +0,0 @@ -echo "echo hello" >> sample/infinite.sh -echo hello diff --git a/42sh/sample/ls b/42sh/sample/ls deleted file mode 100644 index 9e2740c6..00000000 --- a/42sh/sample/ls +++ /dev/null @@ -1 +0,0 @@ -ls diff --git a/42sh/sample/mix.sh b/42sh/sample/mix.sh new file mode 100644 index 00000000..9cfd3fc2 --- /dev/null +++ b/42sh/sample/mix.sh @@ -0,0 +1,30 @@ +VAR=10 +if true +then + echo "Salut" ; echo "Correcteur" + while [ $VAR -gt 0 ] + do + until true + do + echo KO SI JE M AFFICHE + done + if true + then + echo OK SI JE M AFFICHE + elif [ -f Makefile ] + then + echo KO SI JE M AFFICHE + else + echo KO SI JE M AFFICHE + fi + echo "Encore un tour" + math VAR - 1 + done +fi + +sleep 2 +echo +echo "My sample :" +sleep 3 +echo +cat sample/mix/mix.sh diff --git a/42sh/sample/mix/mix.sh b/42sh/sample/mix/mix.sh deleted file mode 100644 index 795c1e37..00000000 --- a/42sh/sample/mix/mix.sh +++ /dev/null @@ -1,21 +0,0 @@ -if ls -then - pwd ; echo "Salut" - while ls - do - until pwd - do - echo KO SI JE M AFFICHE - done - if cat faux - then - echo BONJOUR MAKEFILE - elif [ -f Makefile ] - then - echo BONJOUR MAKEFILE - else - echo KO SI JE M M AFFICHE - fi - echo "Encore une" - done -fi diff --git a/42sh/sample/muchloop.sh b/42sh/sample/muchloop.sh new file mode 100644 index 00000000..a4bd4192 --- /dev/null +++ b/42sh/sample/muchloop.sh @@ -0,0 +1,31 @@ +while [ 1 ] +do + while [ 1 ] + do + while [ 1 ] + do + while [ 1 ] + do + while [ 1 ] + do + while [ 1 ] + do + while [ 1 ] + do + while [ 1 ] + do + while [ 1 ] + do + while [ 1 ] + do + echo "SO MUCH LOOOOP" + done + done + done + done + done + done + done + done + done +done diff --git a/42sh/sample/multiredir b/42sh/sample/multiredir deleted file mode 100644 index 0350bb6f..00000000 --- a/42sh/sample/multiredir +++ /dev/null @@ -1,3 +0,0 @@ -cat < file1 < file2 > file3 > file4 - - diff --git a/42sh/sample/redir/redir.sh b/42sh/sample/redir/redir.sh deleted file mode 100644 index 8b137891..00000000 --- a/42sh/sample/redir/redir.sh +++ /dev/null @@ -1 +0,0 @@ - diff --git a/42sh/sample/script.sh b/42sh/sample/script.sh new file mode 100644 index 00000000..d45d0907 --- /dev/null +++ b/42sh/sample/script.sh @@ -0,0 +1,16 @@ +clear +YES=y +NO=n +echo "Welcome in 42Zash, new corrector, what is your login ?" + +until [ $REP == $YES ] +do + read -p "> " LOGIN + echo + read -p "Ok, fine, your login is $LOGIN, right ?(y/n) " REP + if [ $REP = $NO ] + then + echo + echo "Don't worry let's do it again" + fi +done diff --git a/42sh/sample/stack.sh b/42sh/sample/stack.sh deleted file mode 100644 index 5b2b1f27..00000000 --- a/42sh/sample/stack.sh +++ /dev/null @@ -1,3 +0,0 @@ -cat && ls || ls | cat && ls | cat || ls - - diff --git a/42sh/sample/subshell_pipe b/42sh/sample/subshell.sh similarity index 84% rename from 42sh/sample/subshell_pipe rename to 42sh/sample/subshell.sh index 36c34cd1..8c386eed 100644 --- a/42sh/sample/subshell_pipe +++ b/42sh/sample/subshell.sh @@ -8,3 +8,10 @@ echo aaa \ | (echo bbb 7; cat -e ;echo ccc 7) \ | (echo bbb 8; cat -e ;echo ccc 8) \ | (echo bbb 9; cat -e ;echo ccc 9) + + +sleep 2 +echo "My sample :" +echo +sleep 2 +cat sample/subshell.sh diff --git a/42sh/sample/subshell/subshell01.sh b/42sh/sample/subshell/subshell01.sh deleted file mode 100644 index f1f04671..00000000 --- a/42sh/sample/subshell/subshell01.sh +++ /dev/null @@ -1,2 +0,0 @@ -(ls | cat -pwd ; ls) diff --git a/42sh/sample/toomuchdone.sh b/42sh/sample/toomuchdone.sh new file mode 100644 index 00000000..069b98ff --- /dev/null +++ b/42sh/sample/toomuchdone.sh @@ -0,0 +1,4 @@ +while [ 1 ] +do + ls +done done diff --git a/42sh/sample/until.sh b/42sh/sample/until.sh index c9394c45..845b901e 100644 --- a/42sh/sample/until.sh +++ b/42sh/sample/until.sh @@ -1,8 +1,30 @@ -until [ 1 ] +VAR1=0 +until [ $VAR1 -gt 10 ] do - echo LOOP1 - until [ 1 ] + VAR2=0 + until [ $VAR2 -gt 10 ] do - echo hello + VAR3=0 + until [ $VAR3 -gt 10 ] + do + math VAR3 + 1 + echo "3rd is $VAR3" + done + math VAR2 + 1 + echo "2nd is $VAR2" done -done > file1 + math VAR1 + 1 + echo "1st is $VAR1" + sleep 1 +done +echo +echo "VAR1: $VAR1" +echo "VAR2: $VAR2" +echo "VAR3: $VAR3" + +sleep 2 +echo +echo "My sample :" +sleep 2 +echo +cat sample/until.sh diff --git a/42sh/sample/until/01_until.sh b/42sh/sample/until/01_until.sh deleted file mode 100644 index 2a531998..00000000 --- a/42sh/sample/until/01_until.sh +++ /dev/null @@ -1,11 +0,0 @@ -until cat wefwef -do - until ls - do - pwd ; ls - done - until cat eqwfewf - do - ls | cat - done -done diff --git a/42sh/sample/until2.sh b/42sh/sample/until2.sh deleted file mode 100644 index a8a568d1..00000000 --- a/42sh/sample/until2.sh +++ /dev/null @@ -1,11 +0,0 @@ -ONE=0 -while [ $ONE -le 10 ] -do - TWO=0 - while [ $TWO -le 10 ] - do - echo world - math TWO + 1; - done - math ONE + 1; -done > file1 diff --git a/42sh/sample/var.sh b/42sh/sample/var.sh new file mode 100644 index 00000000..e1dca148 --- /dev/null +++ b/42sh/sample/var.sh @@ -0,0 +1,11 @@ +HELLO=WORLD HELLO=SALUT HELLO="BUENOS DIAS" +echo $HELLO +SALUT=$HELLO +echo $SALUT + +sleep 2 +echo +echo "My sample :" +sleep 2 +echo +cat sample/var.sh diff --git a/42sh/sample/var_01.sh b/42sh/sample/var_01.sh deleted file mode 100644 index d77e8f12..00000000 --- a/42sh/sample/var_01.sh +++ /dev/null @@ -1 +0,0 @@ -HELLO=WORLD diff --git a/42sh/sample/while.sh b/42sh/sample/while.sh index d0fd226b..2f1448c6 100644 --- a/42sh/sample/while.sh +++ b/42sh/sample/while.sh @@ -1,12 +1,24 @@ +VAR=10 while - while - while ls | cat + while [ $VAR -gt 0 ] do - ls - done - do - ls | cat - done + echo "Inside inner loop" | cat -e + math VAR - 1 + done + if [ $VAR -eq -42 ] + then + false + else + true + fi do - pwd + echo "I'm the execution block" + VAR=-42 done + +sleep 2 +echo +echo "My sample :" +sleep 3 +echo +cat sample/while.sh diff --git a/42sh/sample/while/while01.sh b/42sh/sample/while/while01.sh deleted file mode 100644 index 403f8702..00000000 --- a/42sh/sample/while/while01.sh +++ /dev/null @@ -1,11 +0,0 @@ -while ls -do - while cat rwgwghe - do - echo Hello World - done - while pwd - do - echo Bonjour ca va - done -done diff --git a/42sh/sample/while/while02.sh b/42sh/sample/while/while02.sh deleted file mode 100644 index 49c24084..00000000 --- a/42sh/sample/while/while02.sh +++ /dev/null @@ -1,5 +0,0 @@ -ls -while [ 1 ] ; -do - ls | cat -done diff --git a/42sh/sample/while/while03.sh b/42sh/sample/while/while03.sh deleted file mode 100644 index 599bc530..00000000 --- a/42sh/sample/while/while03.sh +++ /dev/null @@ -1,5 +0,0 @@ -ls -for HELLLO in yolo ; -do - ls -done > file1 diff --git a/42sh/sample/while2.sh b/42sh/sample/while2.sh deleted file mode 100644 index 6549f933..00000000 --- a/42sh/sample/while2.sh +++ /dev/null @@ -1,16 +0,0 @@ -ONE=11 -while [ $ONE -gt 1 ] -do - TWO=11 - while [ $TWO -gt 1 ] - do - THREE=11 - while [ $THREE -gt 1 ] - do - echo hello - ((THREE--)) - done - ((TWO--)) - done - ((ONE--)) -done > file1 diff --git a/42sh/sample/while_error.sh b/42sh/sample/while_error.sh deleted file mode 100644 index c8102bb8..00000000 --- a/42sh/sample/while_error.sh +++ /dev/null @@ -1,6 +0,0 @@ -echo hello -while || -do - pwd ; -done -ls | cat diff --git a/42sh/sample/yale/yale0.ex b/42sh/sample/yale/yale0.ex deleted file mode 100644 index 8d12c570..00000000 --- a/42sh/sample/yale/yale0.ex +++ /dev/null @@ -1 +0,0 @@ -< A B | ( C 2> D & E < F ) > G ; H=I J K diff --git a/42sh/sample/yale/yale1.ex b/42sh/sample/yale/yale1.ex deleted file mode 100644 index 372d7e63..00000000 --- a/42sh/sample/yale/yale1.ex +++ /dev/null @@ -1 +0,0 @@ -< A B | C | D | E > F diff --git a/42sh/sample/yale/yale2.ex b/42sh/sample/yale/yale2.ex deleted file mode 100644 index 71e5a6d8..00000000 --- a/42sh/sample/yale/yale2.ex +++ /dev/null @@ -1 +0,0 @@ - A && B || C && D diff --git a/42sh/sample/yale/yale3.ex b/42sh/sample/yale/yale3.ex deleted file mode 100644 index 260a8b62..00000000 --- a/42sh/sample/yale/yale3.ex +++ /dev/null @@ -1 +0,0 @@ -A ; B & C ; D || E diff --git a/42sh/sample/yale/yale5.ex b/42sh/sample/yale/yale5.ex deleted file mode 100644 index 4cd3a71e..00000000 --- a/42sh/sample/yale/yale5.ex +++ /dev/null @@ -1 +0,0 @@ -(A ; B &) | (C || D) && E diff --git a/42sh/sample/yale1.sh b/42sh/sample/yale1.sh deleted file mode 100644 index 8b137891..00000000 --- a/42sh/sample/yale1.sh +++ /dev/null @@ -1 +0,0 @@ - diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 73156a39..00d047bc 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ -/* Updated: 2017/03/26 21:57:37 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 15:18:20 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,6 +46,7 @@ static int handle_instruction(t_list **token, t_btree **ast) return (ret); if (do_lexer_routine(token, stream) > 0) continue ; + token_print(*token); if ((ret = do_parser_routine(token, ast)) == 1 && SH_NO_INTERACTIVE(data->opts)) return (ret); diff --git a/42sh/src/parser/aggregate_sym.c b/42sh/src/parser/aggregate_sym.c index d589639d..7fc190fd 100644 --- a/42sh/src/parser/aggregate_sym.c +++ b/42sh/src/parser/aggregate_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/11 15:58:38 by ariard #+# #+# */ -/* Updated: 2017/03/24 23:26:22 by ariard ### ########.fr */ +/* Updated: 2017/03/27 17:23:36 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -89,6 +89,7 @@ static t_aggrematch g_aggrematch[] = {NEWLINE_LIST, TK_ELIF, TK_ELIF, TK_ELIF}, {NEWLINE_LIST, TK_ELSE, TK_ELSE, TK_ELSE}, {NEWLINE_LIST, TK_WHILE, TK_WHILE, TK_WHILE}, + {NEWLINE_LIST, LOOP, LOOP, LOOP}, {NEWLINE_LIST, TK_LBRACE, TK_LBRACE, TK_LBRACE}, {NEWLINE_LIST, TK_UNTIL, TK_UNTIL, TK_UNTIL}, {NEWLINE_LIST, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS}, @@ -148,6 +149,7 @@ static t_aggrematch g_aggrematch[] = {CMD_SUFFIX, CMD_WORD, SIMPLE_COMMAND, CMD_PREFIX}, {CMD_SUFFIX, CMD_NAME, SIMPLE_COMMAND, CMD_NAME}, {CMD_SUFFIX, CMD_SUPERIOR, CMD_SUPERIOR, CMD_SUPERIOR}, + {CMD_SUFFIX, COMPOUND_LIST, COMPOUND_LIST, COMPOUND_LIST}, {CMD_SUFFIX, PIPE_SEMI_SEQUENCE, PIPE_SEMI_SEQUENCE, PIPE_SEMI_SEQUENCE}, {CMD_SUFFIX, PIPE_CLOSE_SEQUENCE, PIPE_CLOSE_SEQUENCE, PIPE_CLOSE_SEQUENCE}, {CMD_PREFIX, LINEBREAK, SIMPLE_COMMAND, 0}, diff --git a/42sh/src/parser/eval_sym.c b/42sh/src/parser/eval_sym.c index a8582698..94747a30 100644 --- a/42sh/src/parser/eval_sym.c +++ b/42sh/src/parser/eval_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/11 16:11:21 by ariard #+# #+# */ -/* Updated: 2017/03/24 23:26:06 by ariard ### ########.fr */ +/* Updated: 2017/03/27 17:29:01 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -605,6 +605,7 @@ static t_stackmatch g_stackmatch[] = {NEWLINE_LIST, FOR_WORDLIST}, {NEWLINE_LIST, TK_IN}, {NEWLINE_LIST, TK_WHILE}, + {NEWLINE_LIST, LOOP}, {NEWLINE_LIST, FUNC_NAME}, {NEWLINE_LIST, TK_UNTIL}, {NEWLINE_LIST, TK_IF}, diff --git a/42sh/src/parser/produce_sym.c b/42sh/src/parser/produce_sym.c index ab5feb97..3a989fb5 100644 --- a/42sh/src/parser/produce_sym.c +++ b/42sh/src/parser/produce_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 17:58:34 by ariard #+# #+# */ -/* Updated: 2017/03/23 16:47:59 by ariard ### ########.fr */ +/* Updated: 2017/03/27 17:22:10 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -71,7 +71,7 @@ static t_prodmatch g_prodmatch[] = {TK_ASSIGNMENT_WORD, NEWLINE_LIST, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, CMD_NAME, CMD_SUFFIX}, {TK_ASSIGNMENT_WORD, CMD_SUPERIOR, CMD_SUFFIX}, - {TK_ASSIGNMENT_WORD, COMPOUND_LIST, CMD_SUFFIX}, + {TK_ASSIGNMENT_WORD, COMPOUND_LIST, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, COMPLETE_CONDITION, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, CONDITION, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, AND_OR, CMD_PREFIX}, @@ -94,6 +94,7 @@ static t_prodmatch g_prodmatch[] = {TK_NEWLINE, TK_RBRACE, CMD_NAME}, {TK_NEWLINE, TK_IN, NEWLINE_LIST}, {TK_NEWLINE, TK_WHILE, NEWLINE_LIST}, + {TK_NEWLINE, LOOP, NEWLINE_LIST}, {TK_NEWLINE, TK_UNTIL, NEWLINE_LIST}, {TK_NEWLINE, TK_FOR, NEWLINE_LIST}, {TK_NEWLINE, TK_IF, NEWLINE_LIST}, From bf953db03fdaed5a0f6372f7fb24aa37e34a4470 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 27 Mar 2017 18:07:36 +0200 Subject: [PATCH 14/18] sample script --- 42sh/another_file | 248 ---------------------------------------------- 42sh/file | 20 ---- 2 files changed, 268 deletions(-) delete mode 100644 42sh/another_file delete mode 100644 42sh/file diff --git a/42sh/another_file b/42sh/another_file deleted file mode 100644 index ab0fd48c..00000000 --- a/42sh/another_file +++ /dev/null @@ -1,248 +0,0 @@ -hello$$ -hello$$ -bonjour$$ -salut$$ -comment$$ -src/builtin/bt_env_opt.c$$ -src/builtin/bt_read_get.c$$ -src/builtin/bt_read_term.c$$ -src/builtin/builtin_cd.c$$ -src/builtin/builtin_echo.c$$ -src/builtin/builtin_env.c$$ -src/builtin/builtin_exit.c$$ -src/builtin/builtin_export.c$$ -src/builtin/builtin_func.c$$ -src/builtin/builtin_hash.c$$ -src/builtin/builtin_history.c$$ -src/builtin/builtin_math.c$$ -src/builtin/builtin_read.c$$ -src/builtin/builtin_setenv.c$$ -src/builtin/builtin_unset.c$$ -src/builtin/builtin_unsetenv.c$$ -src/builtin/is_builtin.c$$ -src/completion/c_arrow.c$$ -src/completion/c_clear.c$$ -src/completion/c_find_abspath.c$$ -src/completion/c_find_binary.c$$ -src/completion/c_find_env.c$$ -src/completion/c_find_files.c$$ -src/completion/c_init.c$$ -src/completion/c_match.c$$ -src/completion/c_match_glob.c$$ -src/completion/c_match_update.c$$ -src/completion/c_misc.c$$ -src/completion/c_output.c$$ -src/completion/c_parser.c$$ -src/completion/c_pathsolver.c$$ -src/completion/c_printer.c$$ -src/completion/c_sizing.c$$ -src/completion/c_terminal.c$$ -src/completion/completion.c$$ -src/exec/ast_free.c$$ -src/exec/bad_fd.c$$ -src/exec/exec_ampersand.c$$ -src/exec/exec_and_if.c$$ -src/exec/exec_bang.c$$ -src/exec/exec_case_branch.c$$ -src/exec/exec_destroy.c$$ -src/exec/exec_elif.c$$ -src/exec/exec_else.c$$ -src/exec/exec_func.c$$ -src/exec/exec_init.c$$ -src/exec/exec_leaf.c$$ -src/exec/exec_or_if.c$$ -src/exec/exec_pipe.c$$ -src/exec/exec_popfds.c$$ -src/exec/exec_pushfds.c$$ -src/exec/exec_semi.c$$ -src/exec/exec_var.c$$ -src/exec/fd_is_valid.c$$ -src/exec/ft_exec.c$$ -src/exec/ft_findexec.c$$ -src/exec/is_function.c$$ -src/exec/mark_process_status.c$$ -src/exec/node_copy.c$$ -src/exec/pfree_cmd.c$$ -src/exec/pfree_cond.c$$ -src/exec/pfree_func.c$$ -src/exec/pfree_list.c$$ -src/exec/pfree_subshell.c$$ -src/exec/plaunch_brace.c$$ -src/exec/plaunch_builtin.c$$ -src/exec/plaunch_case.c$$ -src/exec/plaunch_empty.c$$ -src/exec/plaunch_file.c$$ -src/exec/plaunch_for.c$$ -src/exec/plaunch_function.c$$ -src/exec/plaunch_if.c$$ -src/exec/plaunch_subshell.c$$ -src/exec/plaunch_until.c$$ -src/exec/plaunch_while.c$$ -src/exec/process_launch.c$$ -src/exec/process_redirect.c$$ -src/exec/process_set.c$$ -src/exec/process_setgroup.c$$ -src/exec/process_setsig.c$$ -src/exec/pset_brace.c$$ -src/exec/pset_case.c$$ -src/exec/pset_cmd.c$$ -src/exec/pset_for.c$$ -src/exec/pset_if.c$$ -src/exec/pset_subshell.c$$ -src/exec/pset_until.c$$ -src/exec/pset_while.c$$ -src/exec/redir_copy.c$$ -src/exec/redir_free.c$$ -src/exec/redirect_dgreat.c$$ -src/exec/redirect_dless.c$$ -src/exec/redirect_great.c$$ -src/exec/redirect_greatand.c$$ -src/exec/redirect_less.c$$ -src/exec/redirect_lessand.c$$ -src/exec/set_exitstatus.c$$ -src/exec/token_to_argv.c$$ -src/glob/command_getoutput.c$$ -src/glob/dir_glob.c$$ -src/glob/esc_print.c$$ -src/glob/expand_bquote.c$$ -src/glob/expand_brace.c$$ -src/glob/expand_esc.c$$ -src/glob/expand_home.c$$ -src/glob/expand_var.c$$ -src/glob/ft_strsplit_esc.c$$ -src/glob/ft_strsplit_spe.c$$ -src/glob/gen_tab_esc.c$$ -src/glob/glob.c$$ -src/glob/is_char_esc.c$$ -src/glob/match_pattern.c$$ -src/glob/tab_esc_copy.c$$ -src/glob/word_is_assignment.c$$ -src/hash_table/ft_add_hash.c$$ -src/hash_table/hash.c$$ -src/hash_table/hash_free.c$$ -src/hash_table/hash_str.c$$ -src/hash_table/is_hash.c$$ -src/history/add_str_in_history.c$$ -src/history/history.c$$ -src/history/history_parsing.c$$ -src/history/history_parsing_toolz.c$$ -src/history/history_parsing_toolz_2.c$$ -src/history/list_toolz.c$$ -src/history/surch_in_history.c$$ -src/job_control/builtin_bg.c$$ -src/job_control/builtin_fg.c$$ -src/job_control/builtin_jobs.c$$ -src/job_control/do_job_notification.c$$ -src/job_control/has_running_job.c$$ -src/job_control/has_stopped_job.c$$ -src/job_control/job_addprocess.c$$ -src/job_control/job_cmp_id.c$$ -src/job_control/job_format.c$$ -src/job_control/job_format_head.c$$ -src/job_control/job_free.c$$ -src/job_control/job_getprocess.c$$ -src/job_control/job_getrank.c$$ -src/job_control/job_hup_all.c$$ -src/job_control/job_is_completed.c$$ -src/job_control/job_is_stopped.c$$ -src/job_control/job_notify_change.c$$ -src/job_control/job_notify_new.c$$ -src/job_control/job_remove.c$$ -src/job_control/job_run.c$$ -src/job_control/job_update_id.c$$ -src/job_control/job_update_status.c$$ -src/job_control/job_wait.c$$ -src/job_control/jobc_destroy.c$$ -src/job_control/mark_job_as_running.c$$ -src/job_control/pprint_brace.c$$ -src/job_control/pprint_case.c$$ -src/job_control/pprint_cmd.c$$ -src/job_control/pprint_for.c$$ -src/job_control/pprint_function.c$$ -src/job_control/pprint_if.c$$ -src/job_control/pprint_subshell.c$$ -src/job_control/pprint_until.c$$ -src/job_control/pprint_while.c$$ -src/job_control/process_cmp_pid.c$$ -src/job_control/process_format.c$$ -src/job_control/process_free.c$$ -src/job_control/put_job_in_background.c$$ -src/job_control/put_job_in_foreground.c$$ -src/job_control/sigchld_handler.c$$ -src/job_control/sigint_handler.c$$ -src/job_control/sigtstp_handler.c$$ -src/job_control/sigttin_handler.c$$ -src/job_control/sigttou_handler.c$$ -src/lexer/do_lexer_routine.c$$ -src/lexer/get_lexer_stack.c$$ -src/lexer/get_lexer_stack2.c$$ -src/lexer/get_reserved_words.c$$ -src/lexer/get_state_global.c$$ -src/lexer/get_state_redir.c$$ -src/lexer/insert_newline.c$$ -src/lexer/isrw_delim.c$$ -src/lexer/keep_last_type.c$$ -src/lexer/lexer_backslash.c$$ -src/lexer/lexer_bquote.c$$ -src/lexer/lexer_curly_braces.c$$ -src/lexer/lexer_default.c$$ -src/lexer/lexer_delim.c$$ -src/lexer/lexer_destroy.c$$ -src/lexer/lexer_dquote.c$$ -src/lexer/lexer_end.c$$ -src/lexer/lexer_great.c$$ -src/lexer/lexer_heredoc.c$$ -src/lexer/lexer_init.c$$ -src/lexer/lexer_less.c$$ -src/lexer/lexer_lex.c$$ -src/lexer/lexer_newline.c$$ -src/lexer/lexer_number.c$$ -src/lexer/lexer_paren.c$$ -src/lexer/lexer_quote.c$$ -src/lexer/lexer_sep.c$$ -src/lexer/lexer_word.c$$ -src/lexer/token_append.c$$ -src/lexer/token_cmp_type.c$$ -src/lexer/token_free.c$$ -src/lexer/token_init.c$$ -src/lexer/token_print.c$$ -src/line_editing/control_features.c$$ -src/line_editing/ft_prompt.c$$ -src/line_editing/get_key.c$$ -src/line_editing/readline.c$$ -src/line_editing/resize.c$$ -src/main/data_exit.c$$ -src/main/data_init.c$$ -src/main/data_singleton.c$$ -src/main/ft_putast.c$$ -src/main/main.c$$ -src/main/shell_init.c$$ -src/main/shell_reset.c$$ -src/parser/add_bang.c$$ -src/parser/add_case.c$$ -src/parser/add_cmd.c$$ -src/parser/add_condition.c$$ -src/parser/add_func.c$$ -src/parser/add_loop.c$$ -src/parser/add_number.c$$ -src/parser/add_redir.c$$ -src/parser/add_sep.c$$ -src/parser/add_subshell.c$$ -src/parser/aggregate_sym.c$$ -src/parser/build_tree.c$$ -src/parser/do_parser_routine.c$$ -src/parser/error_syntax.c$$ -src/parser/eval_sym.c$$ -src/parser/ft_parse.c$$ -src/parser/heredoc_parser.c$$ -src/parser/parser_destroy.c$$ -src/parser/parser_init.c$$ -src/parser/pop_stack.c$$ -src/parser/produce_sym.c$$ -src/parser/push_stack.c$$ -src/parser/read_stack.c$$ -src/parser/redir_init.c$$ -src/parser/stack_init.c$$ -src/parser/sym_free.c$$ -src/parser/tree_func_free.c$$ -src/parser/tree_wrapper.c$$ diff --git a/42sh/file b/42sh/file deleted file mode 100644 index 4b2174a6..00000000 --- a/42sh/file +++ /dev/null @@ -1,20 +0,0 @@ -/Users/ariard/Projects/42sh -/Users/ariard/Projects/42sh -42ShellTester -42sh -Makefile -README.md -STDBUG -another_file -auteur -donovan_segaults_06-02 -file -includes -libft -objs -pdf -sample -scriptheader.sh -src -test -update_makefile.sh From 41b42d88033bfd2655433ed8d930acb87ddd9353 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 18:20:25 +0200 Subject: [PATCH 15/18] lexer_bang and lexer_dquote --- 42sh/Makefile | 1 + 42sh/includes/lexer.h | 4 +++- 42sh/src/completion/c_match.c | 4 ++-- 42sh/src/lexer/get_state_global.c | 5 +++-- 42sh/src/lexer/lexer_bang.c | 31 +++++++++++++++++++++++++++++++ 42sh/src/lexer/lexer_dquote.c | 4 ++-- 42sh/src/lexer/lexer_lex.c | 3 ++- 42sh/src/lexer/lexer_sep.c | 2 +- 8 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 42sh/src/lexer/lexer_bang.c diff --git a/42sh/Makefile b/42sh/Makefile index 181c8a0a..ada05fc1 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -226,6 +226,7 @@ lexer/insert_newline.c\ lexer/isrw_delim.c\ lexer/keep_last_type.c\ lexer/lexer_backslash.c\ +lexer/lexer_bang.c\ lexer/lexer_bquote.c\ lexer/lexer_curly_braces.c\ lexer/lexer_default.c\ diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index 93fa6b49..f52902bb 100644 --- a/42sh/includes/lexer.h +++ b/42sh/includes/lexer.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */ -/* Updated: 2017/03/23 15:18:36 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:17:39 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,6 +24,7 @@ enum e_lexstate HEREDOC, NEWLINE, DELIM, + BANG, SEP, WORD, NUMBER, @@ -99,6 +100,7 @@ int lexer_default(t_list **alst, t_lexer *lexer); int lexer_newline(t_list **alst, t_lexer *lexer); int lexer_heredoc(t_list **alst, t_lexer *lexer); int lexer_delim(t_list **alst, t_lexer *lexer); +int lexer_bang(t_list **alst, t_lexer *lexer); int lexer_sep(t_list **alst, t_lexer *lexer); int lexer_word(t_list **alst, t_lexer *lexer); int lexer_number(t_list **alst, t_lexer *lexer); diff --git a/42sh/src/completion/c_match.c b/42sh/src/completion/c_match.c index 36adb113..602462c1 100644 --- a/42sh/src/completion/c_match.c +++ b/42sh/src/completion/c_match.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/10/15 13:27:14 by alao #+# #+# */ -/* Updated: 2017/03/27 17:48:25 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:10:25 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ static int c_is_delim(char c) return (0); } -char *c_strdupi(char *s, int (*f)(char)) +char *c_strdupi(char *s, int (*f)(char)) { int i; char *str; diff --git a/42sh/src/lexer/get_state_global.c b/42sh/src/lexer/get_state_global.c index aa08fe4e..12796d40 100644 --- a/42sh/src/lexer/get_state_global.c +++ b/42sh/src/lexer/get_state_global.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */ -/* Updated: 2017/03/24 14:51:00 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:13:03 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,8 @@ t_lexstate get_state_global(t_lexer *lexer) cl = lexer->pos ? lexer->str[lexer->pos - 1] : 0; ret = 0; if ((ft_is_delim(c) && (ret = DELIM)) - || ((c == '&' || c == ';' || c == '|' || c == '!') && (ret = SEP)) + || ((c == '&' || c == ';' || c == '|') && (ret = SEP)) + || ((c == '!') && (ret = BANG)) || ((c == '\\') && (ret = BACKSLASH)) || ((c == '\n') && (ret = NEWLINE)) || ((c == '\'') && (ret = QUOTE)) diff --git a/42sh/src/lexer/lexer_bang.c b/42sh/src/lexer/lexer_bang.c new file mode 100644 index 00000000..14042405 --- /dev/null +++ b/42sh/src/lexer/lexer_bang.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lexer_bang.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/27 18:12:03 by jhalford #+# #+# */ +/* Updated: 2017/03/27 18:18:55 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int lexer_bang(t_list **alst, t_lexer *lexer) +{ + t_token *token; + + token = (*alst)->content; + if (token->type) + { + token->type = TK_BANG; + lexer->state = DEFAULT; + lexer->pos++; + return (lexer_lex(&(*alst)->next, lexer)); + } + token->type = TK_WORD; + lexer->state = WORD; + lexer->pos++; + return (lexer_lex(alst, lexer)); +} diff --git a/42sh/src/lexer/lexer_dquote.c b/42sh/src/lexer/lexer_dquote.c index 51e50643..0c9f7e9b 100644 --- a/42sh/src/lexer/lexer_dquote.c +++ b/42sh/src/lexer/lexer_dquote.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */ -/* Updated: 2017/03/24 16:08:35 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:19:57 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,7 +25,7 @@ int lexer_dquote(t_list **alst, t_lexer *lexer) else push(&lexer->stack, DQUOTE); } - else if (lexer->str[lexer->pos] == '\\') + else if (lexer->str[lexer->pos] == '\\' && lexer->str[lexer->pos + 1] == 0) { lexer->pos++; if (lexer->str[lexer->pos] == 0) diff --git a/42sh/src/lexer/lexer_lex.c b/42sh/src/lexer/lexer_lex.c index 53cec923..180a01c9 100644 --- a/42sh/src/lexer/lexer_lex.c +++ b/42sh/src/lexer/lexer_lex.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 17:08:51 by jhalford #+# #+# */ -/* Updated: 2017/03/22 18:13:29 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:13:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ int (*g_lexer[])(t_list **alst, t_lexer *lexer) = &lexer_heredoc, &lexer_newline, &lexer_delim, + &lexer_bang, &lexer_sep, &lexer_word, &lexer_number, diff --git a/42sh/src/lexer/lexer_sep.c b/42sh/src/lexer/lexer_sep.c index b7a5c67f..c0e1745f 100644 --- a/42sh/src/lexer/lexer_sep.c +++ b/42sh/src/lexer/lexer_sep.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 16:29:57 by jhalford #+# #+# */ -/* Updated: 2017/03/20 15:23:35 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:11:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ From 60200721d7f10edfe349f4efb9334863c0a2ebca Mon Sep 17 00:00:00 2001 From: gwojda Date: Mon, 27 Mar 2017 18:51:27 +0200 Subject: [PATCH 16/18] fix somme bugs completion rematch --- 42sh/src/completion/c_find_env.c | 2 +- 42sh/src/completion/c_match.c | 2 +- 42sh/src/completion/c_match_update.c | 7 +++---- 42sh/src/history/history_parsing_toolz.c | 2 +- 42sh/src/lexer/lexer_backslash.c | 4 ++-- 42sh/src/lexer/lexer_dquote.c | 3 ++- 42sh/src/line_editing/readline.c | 3 +-- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/42sh/src/completion/c_find_env.c b/42sh/src/completion/c_find_env.c index 18686006..0ad450d1 100644 --- a/42sh/src/completion/c_find_env.c +++ b/42sh/src/completion/c_find_env.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/09 15:50:24 by gwojda #+# #+# */ -/* Updated: 2017/03/23 19:07:56 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:50:23 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/completion/c_match.c b/42sh/src/completion/c_match.c index 36adb113..ee501368 100644 --- a/42sh/src/completion/c_match.c +++ b/42sh/src/completion/c_match.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/10/15 13:27:14 by alao #+# #+# */ -/* Updated: 2017/03/27 17:48:25 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:37:39 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/completion/c_match_update.c b/42sh/src/completion/c_match_update.c index e9195ea9..bda1b63b 100644 --- a/42sh/src/completion/c_match_update.c +++ b/42sh/src/completion/c_match_update.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 12:03:30 by alao #+# #+# */ -/* Updated: 2017/03/22 12:25:26 by alao ### ########.fr */ +/* Updated: 2017/03/27 18:50:28 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,7 +25,6 @@ static int c_refresh_match(t_comp *c, long int keypress) kpconv[1] = '\0'; tmp = c->match ? ft_strjoin(c->match, kpconv) : ft_strdup(kpconv); c->match ? ft_memdel((void *)&c->match) : (0); - c->match = ft_strdup(tmp); tmp ? ft_memdel((void *)&tmp) : (0); tmp = ft_strjoin(c->rcmd, kpconv); c->rcmd ? ft_memdel((void *)&c->rcmd) : (0); @@ -57,12 +56,12 @@ int c_rematch(t_comp *c, long int keypress) c_term_clear(c); c_refresh_match(c, keypress); c_clear_lst(c); + ft_print(keypress, &s->line.input, &s->line.pos); c_matching(s, c); if (s->comp && c->lst == NULL) c_clear(s); else if (s->comp && c->lst == c->lst->next) - return (1); - ft_print(keypress, &s->line.input, &s->line.pos); + return (ft_putchar('\b') + 1); return (1); } else diff --git a/42sh/src/history/history_parsing_toolz.c b/42sh/src/history/history_parsing_toolz.c index 3c384222..c6d0272f 100644 --- a/42sh/src/history/history_parsing_toolz.c +++ b/42sh/src/history/history_parsing_toolz.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/25 14:09:39 by gwojda #+# #+# */ -/* Updated: 2017/03/27 17:59:50 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:07:49 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_backslash.c b/42sh/src/lexer/lexer_backslash.c index 2a0a62c0..bfcf5f5a 100644 --- a/42sh/src/lexer/lexer_backslash.c +++ b/42sh/src/lexer/lexer_backslash.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* lexer_backslash.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 11:56:49 by jhalford #+# #+# */ -/* Updated: 2017/03/27 02:16:36 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:14:22 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_dquote.c b/42sh/src/lexer/lexer_dquote.c index 51e50643..956ca773 100644 --- a/42sh/src/lexer/lexer_dquote.c +++ b/42sh/src/lexer/lexer_dquote.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */ -/* Updated: 2017/03/24 16:08:35 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:15:29 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,6 +30,7 @@ int lexer_dquote(t_list **alst, t_lexer *lexer) lexer->pos++; if (lexer->str[lexer->pos] == 0) return (push(&lexer->stack, BACKSLASH) ? 0 : 0); + token_append(token, lexer, 1, 0); } else if (lexer->str[lexer->pos] == '`' && (lexer->state = BQUOTE)) return (lexer_lex(alst, lexer)); diff --git a/42sh/src/line_editing/readline.c b/42sh/src/line_editing/readline.c index 32788265..c88c7dfe 100644 --- a/42sh/src/line_editing/readline.c +++ b/42sh/src/line_editing/readline.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ -/* Updated: 2017/03/27 17:38:51 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 18:10:21 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,7 +35,6 @@ int readline(int has_prompt, char **input) if (has_prompt) ret = ft_history_parsing(has_prompt, input); ft_strdel(&data_singleton()->line.copy_tmp); - DG("ret = \"%s\"", *input); if (tcsetattr(0, TCSANOW, ft_save_termios(0)) == -1) return (-1); return (ret); From 1fb76725c2b3e40c710cdc45ece34625e811aa23 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 27 Mar 2017 18:53:33 +0200 Subject: [PATCH 17/18] no leaks env -bad option --- 42sh/src/builtin/builtin_env.c | 5 ++++- 42sh/src/lexer/get_state_global.c | 2 +- 42sh/src/lexer/lexer_bang.c | 5 +++-- 42sh/src/main/main.c | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/42sh/src/builtin/builtin_env.c b/42sh/src/builtin/builtin_env.c index 73c3f826..ad5da964 100644 --- a/42sh/src/builtin/builtin_env.c +++ b/42sh/src/builtin/builtin_env.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/22 16:20:31 by gwojda #+# #+# */ -/* Updated: 2017/03/25 20:40:41 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:52:26 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -71,7 +71,10 @@ int builtin_env(const char *path, (void)envp; if (bt_env_parse(&dat, (char**)argv)) + { + ft_sstrfree(dat.custom_env); return (ft_perror("env") && SH_ERR("usage: %s", ENV_USAGE)); + } if (!*dat.av_data) return (display_env(dat.custom_env)); else if ((pid = fork()) == 0) diff --git a/42sh/src/lexer/get_state_global.c b/42sh/src/lexer/get_state_global.c index 12796d40..b741215b 100644 --- a/42sh/src/lexer/get_state_global.c +++ b/42sh/src/lexer/get_state_global.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */ -/* Updated: 2017/03/27 18:13:03 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:39:55 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_bang.c b/42sh/src/lexer/lexer_bang.c index 14042405..9fc18aab 100644 --- a/42sh/src/lexer/lexer_bang.c +++ b/42sh/src/lexer/lexer_bang.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/27 18:12:03 by jhalford #+# #+# */ -/* Updated: 2017/03/27 18:18:55 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:53:10 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,8 @@ int lexer_bang(t_list **alst, t_lexer *lexer) t_token *token; token = (*alst)->content; - if (token->type) + if (!token->type || token->type == TK_SEMI || token->type == TK_NEWLINE + || token->type == TK_AMP) { token->type = TK_BANG; lexer->state = DEFAULT; diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index fb87ef7f..f07ed64f 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ -/* Updated: 2017/03/27 18:08:20 by ariard ### ########.fr */ +/* Updated: 2017/03/27 18:28:37 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ From 7d4880b2b7097481774e59363ecb39d7d7181feb Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 19:42:49 +0200 Subject: [PATCH 18/18] :thumbsup: close #215 --- 42sh/src/exec/redirect_dless.c | 5 ++--- 42sh/src/main/shell_init.c | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/42sh/src/exec/redirect_dless.c b/42sh/src/exec/redirect_dless.c index d8063a57..e204d3c3 100644 --- a/42sh/src/exec/redirect_dless.c +++ b/42sh/src/exec/redirect_dless.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 12:36:10 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:45:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 19:41:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,6 @@ int redirect_dless(t_redir *redir) str = redir->heredoc_data; write(fds[PIPE_WRITE], str, ft_strlen(str)); close(fds[PIPE_WRITE]); - dup2(fds[PIPE_READ], redir->n); - close(fds[PIPE_READ]); + fd_replace(fds[PIPE_READ], redir->n); return (0); } diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 542f1780..bfd6768d 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/03/27 18:08:56 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 19:41:47 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -100,5 +100,6 @@ int shell_init(int ac, char **av, char **env) if (SH_IS_INTERACTIVE(data->opts) && interactive_settings() < 0) return (-1); shell_fds_init(); + shell_fds_push(); return (0); }