diff --git a/42sh/42ShellTester/logmini b/42sh/42ShellTester/logmini new file mode 100644 index 00000000..e06dc5fc --- /dev/null +++ b/42sh/42ShellTester/logmini @@ -0,0 +1,259 @@ +...x...~......xx........~...........~.....~........... + +---------------------------------------------------------------- + +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 "TOKEN201703291444" + + STDOUT: + FAILURE expected_to match_regex `TOKEN201703291444` + (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.4f2AkmTXni/Render + 09: TERM_PROGRAM_VERSION=3.0.10 + 10: TERM_SESSION_ID=w0t0p0:27D68FBB-A085-467A-8F02-568DA11416F0 + 11: ZSH=/Users/ariard/.oh-my-zsh + 12: USER=ariard + 13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.VotSnLjyD2/Listeners + 14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 15: PAGER=less + 16: TMUX=/private/tmp/tmux-18965/default,460,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=5 + 28: HOME=/Users/ariard + 29: COLORFGBG=7;0 + 30: ITERM_SESSION_ID=w0t0p0:27D68FBB-A085-467A-8F02-568DA11416F0 + 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.4f2AkmTXni/Render + 09: TERM_PROGRAM_VERSION=3.0.10 + 10: TERM_SESSION_ID=w0t0p0:27D68FBB-A085-467A-8F02-568DA11416F0 + 11: ZSH=/Users/ariard/.oh-my-zsh + 12: USER=ariard + 13: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.VotSnLjyD2/Listeners + 14: __CF_USER_TEXT_ENCODING=0x4A15:0x0:0x0 + 15: PAGER=less + 16: TMUX=/private/tmp/tmux-18965/default,460,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=5 + 28: HOME=/Users/ariard + 29: COLORFGBG=7;0 + 30: ITERM_SESSION_ID=w0t0p0:27D68FBB-A085-467A-8F02-568DA11416F0 + 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/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/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 + + MISC: + SUCCESS 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 TOKEN201703291444 + + STDOUT: + SUCCESS expected_to match_regex `TOKEN201703291444` + 01: TOKEN201703291444 + + 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 pending tests: 0 diff --git a/42sh/42ShellTester/spec/bonuses/README.md b/42sh/42ShellTester/spec/bonuses/README.md new file mode 100644 index 00000000..9c789434 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/README.md @@ -0,0 +1,9 @@ +# bonuses + +*[spec](..) > bonuses* + +* [builtins](./builtins) +* [inline-environment-variable](./inline-environment-variable) +* [redirections](./redirections) +* [separators](./separators) +* [tilde-expansion](./tilde-expansion) diff --git a/42sh/42ShellTester/spec/bonuses/builtins/README.md b/42sh/42ShellTester/spec/bonuses/builtins/README.md new file mode 100644 index 00000000..bc79927e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/README.md @@ -0,0 +1,5 @@ +# builtins + +*[spec > bonuses](..) > builtins* + +* [env](./env) diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/README.md b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/README.md new file mode 100644 index 00000000..f0ba28fc --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/README.md @@ -0,0 +1,61 @@ +# 001-unset-variables + +*[spec > bonuses > builtins > env](..) > 001-unset-variables* + +The purpose of this test is to check that the builtin `env` implement the option `-u` to unset environment variables. +### What is done before test + +```bash +export TESTVARIABLE="${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +env -u HOME -u PATH -u TESTVARIABLE ./display_env + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "HOME=" +expected_to_not match_regex "PATH=" +expected_to_not match_regex "TESTVARIABLE=" + +``` + +### What is expected on error output + +```bash +expected_to be_empty + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/before_exec b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/before_exec new file mode 100644 index 00000000..b5017f3b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/before_exec @@ -0,0 +1 @@ +export TESTVARIABLE="${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/description b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/description new file mode 100644 index 00000000..6d2bc3a8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/description @@ -0,0 +1 @@ +The purpose of this test is to check that the builtin `env` implement the option `-u` to unset environment variables. diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/non-posix b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/non-posix new file mode 100644 index 00000000..8b9aeabf --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/non-posix @@ -0,0 +1 @@ +`env -u` is not registered in the POSIX standard. diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/pending b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/pending new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stderr b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdin b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdin new file mode 100644 index 00000000..96a4be3f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdin @@ -0,0 +1 @@ +env -u HOME -u PATH -u TESTVARIABLE ./display_env diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdout b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdout new file mode 100644 index 00000000..93c94f83 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/001-unset-variables/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "HOME=" +expected_to_not match_regex "PATH=" +expected_to_not match_regex "TESTVARIABLE=" diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/README.md b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/README.md new file mode 100644 index 00000000..d8be155b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/README.md @@ -0,0 +1,61 @@ +# 002-unset-and-set-variable + +*[spec > bonuses > builtins > env](..) > 002-unset-and-set-variable* + +The purpose of this test is to check if env -u works to unset variables for a given binary, we are also checking if an argument not prefix with -u is add to the environment of the given binary.### What is done before test + +```bash +# unset all environment variables except PATH +for VARIABLE in $(env | awk 'BEGIN {FS="="} $0 !~ /^PATH/ {print $1}'); do unset "${VARIABLE}"; done; + +export HOME="/my/home" + +``` + +### Shell commands that are sent to the standard entry + +```bash +env -u HOME TESTVARIABLE=${GLOBAL_TOKEN} ./display_env + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^TESTVARIABLE=${GLOBAL_TOKEN}$" +expected_to_not match_regex "^HOME=" + +``` + +### What is expected on error output + +```bash +expected_to be_empty +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/before_exec b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/before_exec new file mode 100644 index 00000000..072acc45 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/before_exec @@ -0,0 +1,4 @@ +# unset all environment variables except PATH +for VARIABLE in $(env | awk 'BEGIN {FS="="} $0 !~ /^PATH/ {print $1}'); do unset "${VARIABLE}"; done; + +export HOME="/my/home" diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/description b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/description new file mode 100644 index 00000000..d1d70325 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/description @@ -0,0 +1 @@ +The purpose of this test is to check if env -u works to unset variables for a given binary, we are also checking if an argument not prefix with -u is add to the environment of the given binary. \ No newline at end of file diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/non-posix b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/non-posix new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/pending b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/pending new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stderr b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stderr new file mode 100644 index 00000000..c703fdc6 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stderr @@ -0,0 +1 @@ +expected_to be_empty \ No newline at end of file diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdin b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdin new file mode 100644 index 00000000..afb12db8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdin @@ -0,0 +1 @@ +env -u HOME TESTVARIABLE=${GLOBAL_TOKEN} ./display_env diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdout b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdout new file mode 100644 index 00000000..4afc77a6 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/002-unset-and-set-variable/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "^TESTVARIABLE=${GLOBAL_TOKEN}$" +expected_to_not match_regex "^HOME=" diff --git a/42sh/42ShellTester/spec/bonuses/builtins/env/README.md b/42sh/42ShellTester/spec/bonuses/builtins/env/README.md new file mode 100644 index 00000000..905bafab --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/builtins/env/README.md @@ -0,0 +1,6 @@ +# env + +*[spec > bonuses > builtins](..) > env* + +* [001-unset-variables](./001-unset-variables) +* [002-unset-and-set-variable](./002-unset-and-set-variable) diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/README.md b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/README.md new file mode 100644 index 00000000..18832f55 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/README.md @@ -0,0 +1,60 @@ +# 001-modifies-child-environment-1 + +*[spec > bonuses > inline-environment-variable](..) > 001-modifies-child-environment-1* + +The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline. +### What is done before test + +```bash +unset "${GLOBAL_TOKEN}_VARIABLE" + +``` + +### Shell commands that are sent to the standard entry + +```bash +${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE ./display_env +./display_env + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE$" once + +``` + +### What is expected on error output + +```bash +expected_to be_empty + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/before_exec b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/before_exec new file mode 100644 index 00000000..3d157a65 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/before_exec @@ -0,0 +1 @@ +unset "${GLOBAL_TOKEN}_VARIABLE" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/description b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/description new file mode 100644 index 00000000..867b9a4c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/description @@ -0,0 +1 @@ +The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline. diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stderr b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdin b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdin new file mode 100644 index 00000000..ac8a9dc1 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdin @@ -0,0 +1,2 @@ +${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE ./display_env +./display_env diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdout b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdout new file mode 100644 index 00000000..d0fe972f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/001-modifies-child-environment-1/stdout @@ -0,0 +1 @@ +expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE=${GLOBAL_TOKEN}_VALUE$" once diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/README.md b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/README.md new file mode 100644 index 00000000..ec6a634f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/README.md @@ -0,0 +1,62 @@ +# 002-modifies-child-environment-2 + +*[spec > bonuses > inline-environment-variable](..) > 002-modifies-child-environment-2* + +The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline. +### What is done before test + +```bash +unset "${GLOBAL_TOKEN}_VARIABLE" + +``` + +### Shell commands that are sent to the standard entry + +```bash +${GLOBAL_TOKEN}_VARIABLE1=${GLOBAL_TOKEN}_VALUE1 ${GLOBAL_TOKEN}_VARIABLE2=${GLOBAL_TOKEN}_VALUE2 ${GLOBAL_TOKEN}_VARIABLE3=${GLOBAL_TOKEN}_VALUE3 ./display_env +./display_env + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE1=${GLOBAL_TOKEN}_VALUE1$" once +expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE2=${GLOBAL_TOKEN}_VALUE2$" once +expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE3=${GLOBAL_TOKEN}_VALUE3$" once + +``` + +### What is expected on error output + +```bash +expected_to be_empty + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/before_exec b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/before_exec new file mode 100644 index 00000000..3d157a65 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/before_exec @@ -0,0 +1 @@ +unset "${GLOBAL_TOKEN}_VARIABLE" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/description b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/description new file mode 100644 index 00000000..867b9a4c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/description @@ -0,0 +1 @@ +The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline. diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stderr b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdin b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdin new file mode 100644 index 00000000..41cea892 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdin @@ -0,0 +1,2 @@ +${GLOBAL_TOKEN}_VARIABLE1=${GLOBAL_TOKEN}_VALUE1 ${GLOBAL_TOKEN}_VARIABLE2=${GLOBAL_TOKEN}_VALUE2 ${GLOBAL_TOKEN}_VARIABLE3=${GLOBAL_TOKEN}_VALUE3 ./display_env +./display_env diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdout b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdout new file mode 100644 index 00000000..37f7aa70 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/002-modifies-child-environment-2/stdout @@ -0,0 +1,3 @@ +expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE1=${GLOBAL_TOKEN}_VALUE1$" once +expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE2=${GLOBAL_TOKEN}_VALUE2$" once +expected_to match_regex "^${GLOBAL_TOKEN}_VARIABLE3=${GLOBAL_TOKEN}_VALUE3$" once diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/README.md b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/README.md new file mode 100644 index 00000000..c89e7ded --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/README.md @@ -0,0 +1,71 @@ +# 003-modifies-PATH-only + +*[spec > bonuses > inline-environment-variable](..) > 003-modifies-PATH-only* + +The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline. +### What is done before test + +```bash +rm -rf "temporary_directory" +mkdir -p "temporary_directory" +cd "temporary_directory" + +``` + +### Shell commands that are sent to the standard entry + +```bash +PATH=.. write_on_stdout ${GLOBAL_TOKEN} +exit_with_status 42 + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^${GLOBAL_TOKEN}$" + +``` + +### What is expected on error output + +```bash +expected_to_not be_empty +might match_regex "[Cc]ommand not found" + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to_not exit_with_status "42" +expected_to_not exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/before_exec b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/before_exec new file mode 100644 index 00000000..6da5ae48 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/before_exec @@ -0,0 +1,3 @@ +rm -rf "temporary_directory" +mkdir -p "temporary_directory" +cd "temporary_directory" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/description b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/description new file mode 100644 index 00000000..867b9a4c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/description @@ -0,0 +1 @@ +The purpose of this test is to check that a binary may have its environment to be modified by appending variables inline. diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/misc b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/misc new file mode 100644 index 00000000..b982085d --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/misc @@ -0,0 +1,2 @@ +expected_to_not exit_with_status "42" +expected_to_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stderr b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stderr new file mode 100644 index 00000000..e259629c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stderr @@ -0,0 +1,2 @@ +expected_to_not be_empty +might match_regex "[Cc]ommand not found" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdin b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdin new file mode 100644 index 00000000..e318f09a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdin @@ -0,0 +1,2 @@ +PATH=.. write_on_stdout ${GLOBAL_TOKEN} +exit_with_status 42 diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdout b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdout new file mode 100644 index 00000000..ba5eb86a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/003-modifies-PATH-only/stdout @@ -0,0 +1 @@ +expected_to match_regex "^${GLOBAL_TOKEN}$" diff --git a/42sh/42ShellTester/spec/bonuses/inline-environment-variable/README.md b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/README.md new file mode 100644 index 00000000..b210b586 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/inline-environment-variable/README.md @@ -0,0 +1,7 @@ +# inline-environment-variable + +*[spec > bonuses](..) > inline-environment-variable* + +* [001-modifies-child-environment-1](./001-modifies-child-environment-1) +* [002-modifies-child-environment-2](./002-modifies-child-environment-2) +* [003-modifies-PATH-only](./003-modifies-PATH-only) diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/README.md b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/README.md new file mode 100644 index 00000000..1217e4e1 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/README.md @@ -0,0 +1,68 @@ +# 001-append-twice-outputs-together + +*[spec > bonuses > redirections](..) > 001-append-twice-outputs-together* + +A double right redirection opens the file with the oflag `O_APPEND`, so that its size is not truncated to 0 and output is written at the end of file. If the file does not exist, it is created. +In this test, twice outputs are appended to the same file. +### What is done before test + +```bash +rm -f "new_file_stderr_and_stdout" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout_and_stderr ${GLOBAL_TOKEN}_stdout ${GLOBAL_TOKEN}_stderr &>>new_file_stderr_and_stdout + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "${GLOBAL_TOKEN}_stdout" + +``` + +### What is expected on error output + +```bash +expected_to_not match_regex "${GLOBAL_TOKEN}_stderr" + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to create_file "new_file_stderr_and_stdout" matching_regex "${GLOBAL_TOKEN}_stdout$" +expected_to create_file "new_file_stderr_and_stdout" matching_regex "${GLOBAL_TOKEN}_stderr$" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/before_exec b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/before_exec new file mode 100644 index 00000000..21a08a3e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/before_exec @@ -0,0 +1 @@ +rm -f "new_file_stderr_and_stdout" diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/description b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/description new file mode 100644 index 00000000..9f258f1d --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/description @@ -0,0 +1,2 @@ +A double right redirection opens the file with the oflag `O_APPEND`, so that its size is not truncated to 0 and output is written at the end of file. If the file does not exist, it is created. +In this test, twice outputs are appended to the same file. diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/hard b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/hard new file mode 100644 index 00000000..ac178a36 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/hard @@ -0,0 +1 @@ +This test only succeed with the reference ZSH. diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/misc b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/misc new file mode 100644 index 00000000..5ff4505a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/misc @@ -0,0 +1,2 @@ +expected_to create_file "new_file_stderr_and_stdout" matching_regex "${GLOBAL_TOKEN}_stdout$" +expected_to create_file "new_file_stderr_and_stdout" matching_regex "${GLOBAL_TOKEN}_stderr$" diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/non-posix b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/non-posix new file mode 100644 index 00000000..c009338b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/non-posix @@ -0,0 +1 @@ +The POSIX standard does not specify the capability for a Shell to append twice outputs to the same file. diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/pending b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/pending new file mode 100644 index 00000000..e69de29b diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stderr b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stderr new file mode 100644 index 00000000..954fde45 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stderr @@ -0,0 +1 @@ +expected_to_not match_regex "${GLOBAL_TOKEN}_stderr" diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdin b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdin new file mode 100644 index 00000000..95ebe4a6 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdin @@ -0,0 +1 @@ +./write_on_stdout_and_stderr ${GLOBAL_TOKEN}_stdout ${GLOBAL_TOKEN}_stderr &>>new_file_stderr_and_stdout diff --git a/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdout b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdout new file mode 100644 index 00000000..edd840fd --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/001-append-twice-outputs-together/stdout @@ -0,0 +1 @@ +expected_to_not match_regex "${GLOBAL_TOKEN}_stdout" diff --git a/42sh/42ShellTester/spec/bonuses/redirections/README.md b/42sh/42ShellTester/spec/bonuses/redirections/README.md new file mode 100644 index 00000000..3fb4835b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/redirections/README.md @@ -0,0 +1,5 @@ +# redirections + +*[spec > bonuses](..) > redirections* + +* [001-append-twice-outputs-together](./001-append-twice-outputs-together) diff --git a/42sh/42ShellTester/spec/bonuses/separators/README.md b/42sh/42ShellTester/spec/bonuses/separators/README.md new file mode 100644 index 00000000..baa8d80a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/README.md @@ -0,0 +1,7 @@ +# separators + +*[spec > bonuses](..) > separators* + +* [and](./and) +* [mixed](./mixed) +* [or](./or) diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/README.md new file mode 100644 index 00000000..977dc6a0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/README.md @@ -0,0 +1,53 @@ +# 001-run-twice + +*[spec > bonuses > separators > and](..) > 001-run-twice* + +The purpose of this test is to check that the AND operator `&&` works with two valid commands. +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ${GLOBAL_TOKEN}_LEFT && ./write_on_stdout ${GLOBAL_TOKEN}_RIGHT + +``` + +### What is expected on standard output + +```bash +might match_regex "${GLOBAL_TOKEN}_LEFT" +might match_regex "${GLOBAL_TOKEN}_RIGHT" + +``` + +### What is expected on error output + +```bash +might be_empty + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/description b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/description new file mode 100644 index 00000000..6c60d378 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/description @@ -0,0 +1 @@ +The purpose of this test is to check that the AND operator `&&` works with two valid commands. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdin new file mode 100644 index 00000000..793e144e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdin @@ -0,0 +1 @@ +./write_on_stdout ${GLOBAL_TOKEN}_LEFT && ./write_on_stdout ${GLOBAL_TOKEN}_RIGHT diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdout new file mode 100644 index 00000000..65f5ef3a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/001-run-twice/stdout @@ -0,0 +1,2 @@ +might match_regex "${GLOBAL_TOKEN}_LEFT" +might match_regex "${GLOBAL_TOKEN}_RIGHT" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/README.md new file mode 100644 index 00000000..a1fb7113 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/README.md @@ -0,0 +1,61 @@ +# 002-do-not-run-second + +*[spec > bonuses > separators > and](..) > 002-do-not-run-second* + +The purpose of this test is to check that the AND operator `&&` makes the right command to not be executed if the left one exits with an error status code. +The Shell should exit with the status code of the executed command. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 42 && ./write_on_stdout ${GLOBAL_TOKEN} + +``` + +### What is expected on standard output + +```bash +might_not match_regex ${GLOBAL_TOKEN} +might be_empty + +``` + +### What is expected on error output + +```bash +might be_empty + +``` + +### What miscellaneous behaviors are expected + +```bash +might exit_with_status "42" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/description b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/description new file mode 100644 index 00000000..f85a5e86 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/description @@ -0,0 +1,2 @@ +The purpose of this test is to check that the AND operator `&&` makes the right command to not be executed if the left one exits with an error status code. +The Shell should exit with the status code of the executed command. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/misc b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/misc new file mode 100644 index 00000000..cdd865a4 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/misc @@ -0,0 +1 @@ +might exit_with_status "42" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdin new file mode 100644 index 00000000..486986fc --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdin @@ -0,0 +1 @@ +./exit_with_status 42 && ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdout new file mode 100644 index 00000000..b01a27a5 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/002-do-not-run-second/stdout @@ -0,0 +1,2 @@ +might_not match_regex ${GLOBAL_TOKEN} +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/README.md new file mode 100644 index 00000000..cca4c935 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/README.md @@ -0,0 +1,60 @@ +# 003-run-until-failing + +*[spec > bonuses > separators > and](..) > 003-run-until-failing* + +The purpose of this test is to check that using the AND separator `&&` with chained commands results in the execution of all until the first fail. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 0 && ./exit_with_status 0 && ./exit_with_status 0 && ./exit_with_status 0 && ./write_on_stdout ${GLOBAL_TOKEN}_FIRST && ./exit_with_status 42 && ./write_on_stdout ${GLOBAL_TOKEN}_SECOND + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_FIRST" +expected_to_not match_regex "${GLOBAL_TOKEN}_SECOND" + +``` + +### What is expected on error output + +```bash +expected_to be_empty + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to exit_with_status "42" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/description b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/description new file mode 100644 index 00000000..9d47e372 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the AND separator `&&` with chained commands results in the execution of all until the first fail. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/misc b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/misc new file mode 100644 index 00000000..1983dc76 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/misc @@ -0,0 +1 @@ +expected_to exit_with_status "42" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdin new file mode 100644 index 00000000..ade933dd --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdin @@ -0,0 +1 @@ +./exit_with_status 0 && ./exit_with_status 0 && ./exit_with_status 0 && ./exit_with_status 0 && ./write_on_stdout ${GLOBAL_TOKEN}_FIRST && ./exit_with_status 42 && ./write_on_stdout ${GLOBAL_TOKEN}_SECOND diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdout new file mode 100644 index 00000000..16c3d329 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/003-run-until-failing/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "${GLOBAL_TOKEN}_FIRST" +expected_to_not match_regex "${GLOBAL_TOKEN}_SECOND" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/README.md new file mode 100644 index 00000000..0465749c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/README.md @@ -0,0 +1,8 @@ +# and + +*[spec > bonuses > separators](..) > and* + +* [001-run-twice](./001-run-twice) +* [002-do-not-run-second](./002-do-not-run-second) +* [003-run-until-failing](./003-run-until-failing) +* [errors](./errors) diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/README.md new file mode 100644 index 00000000..8f69cde8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/README.md @@ -0,0 +1,63 @@ +# 001-parse-error-at-beginning + +*[spec > bonuses > separators > and > errors](..) > 001-parse-error-at-beginning* + +Parsing test. +The purpose of this test is to check that the AND operator `&&` must be placed after a valid command. +If not, the Shell should display an error and exit with an error status code. +### Shell commands that are sent to the standard entry + +```bash +&& ./write_on_stdout ${GLOBAL_TOKEN} + +``` + +### What is expected on standard output + +```bash +might_not match_regex "${GLOBAL_TOKEN}" +might be_empty + +``` + +### What is expected on error output + +```bash +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" + +``` + +### What miscellaneous behaviors are expected + +```bash +might_not exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/description b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/description new file mode 100644 index 00000000..680a6627 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/description @@ -0,0 +1,3 @@ +Parsing test. +The purpose of this test is to check that the AND operator `&&` must be placed after a valid command. +If not, the Shell should display an error and exit with an error status code. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/misc b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/misc new file mode 100644 index 00000000..c4b48f73 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/misc @@ -0,0 +1 @@ +might_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stderr new file mode 100644 index 00000000..19c209de --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stderr @@ -0,0 +1,2 @@ +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdin new file mode 100644 index 00000000..dc4ada22 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdin @@ -0,0 +1 @@ +&& ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdout new file mode 100644 index 00000000..f78d19db --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/001-parse-error-at-beginning/stdout @@ -0,0 +1,2 @@ +might_not match_regex "${GLOBAL_TOKEN}" +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/README.md new file mode 100644 index 00000000..b28ff2c8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/README.md @@ -0,0 +1,63 @@ +# 002-parse-error-too-much-symbol + +*[spec > bonuses > separators > and > errors](..) > 002-parse-error-too-much-symbol* + +Parsing test. +The purpose of this test is to check that more than two '&' operators are detected as a syntax error. +It should not execute the two commands `write_on_stdout` but display an error and exit with an error status code. +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ${GLOBAL_TOKEN} &&& ./write_on_stdout ${GLOBAL_TOKEN} + +``` + +### What is expected on standard output + +```bash +might_not match_regex "${GLOBAL_TOKEN}" +might be_empty + +``` + +### What is expected on error output + +```bash +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to_not exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/description b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/description new file mode 100644 index 00000000..00c27154 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/description @@ -0,0 +1,3 @@ +Parsing test. +The purpose of this test is to check that more than two '&' operators are detected as a syntax error. +It should not execute the two commands `write_on_stdout` but display an error and exit with an error status code. diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/misc b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/misc new file mode 100644 index 00000000..55d07cd5 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/misc @@ -0,0 +1 @@ +expected_to_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stderr b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stderr new file mode 100644 index 00000000..19c209de --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stderr @@ -0,0 +1,2 @@ +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdin b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdin new file mode 100644 index 00000000..d43aa5f0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdin @@ -0,0 +1 @@ +./write_on_stdout ${GLOBAL_TOKEN} &&& ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdout b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdout new file mode 100644 index 00000000..f78d19db --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/002-parse-error-too-much-symbol/stdout @@ -0,0 +1,2 @@ +might_not match_regex "${GLOBAL_TOKEN}" +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/and/errors/README.md b/42sh/42ShellTester/spec/bonuses/separators/and/errors/README.md new file mode 100644 index 00000000..60f1730e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/and/errors/README.md @@ -0,0 +1,6 @@ +# errors + +*[spec > bonuses > separators > and](..) > errors* + +* [001-parse-error-at-beginning](./001-parse-error-at-beginning) +* [002-parse-error-too-much-symbol](./002-parse-error-too-much-symbol) diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/README.md new file mode 100644 index 00000000..8c6871fb --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/README.md @@ -0,0 +1,59 @@ +# 001-and-or + +*[spec > bonuses > separators > mixed](..) > 001-and-or* + +The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 42 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" + +``` + +### What is expected on error output + +```bash +expected_to be_empty + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/description new file mode 100644 index 00000000..bfa3fc16 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdin new file mode 100644 index 00000000..ead446bc --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdin @@ -0,0 +1 @@ +./exit_with_status 42 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/001-and-or/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/README.md new file mode 100644 index 00000000..e1706492 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/README.md @@ -0,0 +1,59 @@ +# 002-and-or + +*[spec > bonuses > separators > mixed](..) > 002-and-or* + +The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 0 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" + +``` + +### What is expected on error output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/description new file mode 100644 index 00000000..bfa3fc16 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stderr new file mode 100644 index 00000000..e9c877c3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stderr @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdin new file mode 100644 index 00000000..7513ed7b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdin @@ -0,0 +1 @@ +./exit_with_status 0 && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/002-and-or/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/README.md new file mode 100644 index 00000000..d257e648 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/README.md @@ -0,0 +1,59 @@ +# 003-and-or + +*[spec > bonuses > separators > mixed](..) > 003-and-or* + +The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 0 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" + +``` + +### What is expected on error output + +```bash +expected_to be_empty + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/description new file mode 100644 index 00000000..bfa3fc16 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the two separators AND `&&` and OR `||` applies the good logic: The second command is executed if the first one succeeds, and the third command is executed if the second one fails or is not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdin new file mode 100644 index 00000000..e695ff1a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdin @@ -0,0 +1 @@ +./exit_with_status 0 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/003-and-or/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/README.md new file mode 100644 index 00000000..eb66cf3f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/README.md @@ -0,0 +1,59 @@ +# 004-or-and + +*[spec > bonuses > separators > mixed](..) > 004-or-and* + +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 42 || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS + +``` + +### What is expected on standard output + +```bash +expected_to be_empty + +``` + +### What is expected on error output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to exit_with_status "21" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/description new file mode 100644 index 00000000..fba00623 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/misc new file mode 100644 index 00000000..82d70611 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/misc @@ -0,0 +1 @@ +expected_to exit_with_status "21" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stderr new file mode 100644 index 00000000..e9c877c3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stderr @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdin new file mode 100644 index 00000000..29391e99 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdin @@ -0,0 +1 @@ +./exit_with_status 42 || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdout new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/004-or-and/stdout @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/README.md new file mode 100644 index 00000000..bb944740 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/README.md @@ -0,0 +1,59 @@ +# 005-or-and + +*[spec > bonuses > separators > mixed](..) > 005-or-and* + +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 42 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" + +``` + +### What is expected on error output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to exit_with_status "21" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/description new file mode 100644 index 00000000..fba00623 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/misc new file mode 100644 index 00000000..82d70611 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/misc @@ -0,0 +1 @@ +expected_to exit_with_status "21" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stderr new file mode 100644 index 00000000..e9c877c3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stderr @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_ERROR" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdin new file mode 100644 index 00000000..6d9fee3a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdin @@ -0,0 +1 @@ +./exit_with_status 42 || ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS && ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/005-or-and/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/README.md new file mode 100644 index 00000000..aa7f35bd --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/README.md @@ -0,0 +1,59 @@ +# 006-or-and + +*[spec > bonuses > separators > mixed](..) > 006-or-and* + +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 0 || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" + +``` + +### What is expected on error output + +```bash +expected_to be_empty + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/description b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/description new file mode 100644 index 00000000..fba00623 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the two separators OR `||` and AND `&&` applies the good logic: The second command is executed if the first one fails, and the third command is executed if the second one succeeds or is not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/misc b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stderr b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdin b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdin new file mode 100644 index 00000000..7dab07c6 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdin @@ -0,0 +1 @@ +./exit_with_status 0 || ./write_on_stderr ${GLOBAL_TOKEN}_ERROR 21 && ./write_on_stdout ${GLOBAL_TOKEN}_SUCCESS diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdout b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdout new file mode 100644 index 00000000..258a6d56 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/006-or-and/stdout @@ -0,0 +1 @@ +expected_to match_regex "${GLOBAL_TOKEN}_SUCCESS" diff --git a/42sh/42ShellTester/spec/bonuses/separators/mixed/README.md b/42sh/42ShellTester/spec/bonuses/separators/mixed/README.md new file mode 100644 index 00000000..a6863e70 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/mixed/README.md @@ -0,0 +1,10 @@ +# mixed + +*[spec > bonuses > separators](..) > mixed* + +* [001-and-or](./001-and-or) +* [002-and-or](./002-and-or) +* [003-and-or](./003-and-or) +* [004-or-and](./004-or-and) +* [005-or-and](./005-or-and) +* [006-or-and](./006-or-and) diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/README.md new file mode 100644 index 00000000..1d3ce380 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/README.md @@ -0,0 +1,53 @@ +# 001-run-first-only + +*[spec > bonuses > separators > or](..) > 001-run-first-only* + +The purpose of this test is to check that the OR operator `||` makes the right command to not be executed if the left one exits with a success status. +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ${GLOBAL_TOKEN}_LEFT || ./write_on_stdout ${GLOBAL_TOKEN}_RIGHT + +``` + +### What is expected on standard output + +```bash +might match_regex ${GLOBAL_TOKEN}_LEFT +might_not match_regex ${GLOBAL_TOKEN}_RIGHT + +``` + +### What is expected on error output + +```bash +might be_empty + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/description b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/description new file mode 100644 index 00000000..faf0dca8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/description @@ -0,0 +1 @@ +The purpose of this test is to check that the OR operator `||` makes the right command to not be executed if the left one exits with a success status. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdin new file mode 100644 index 00000000..e167faf4 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdin @@ -0,0 +1 @@ +./write_on_stdout ${GLOBAL_TOKEN}_LEFT || ./write_on_stdout ${GLOBAL_TOKEN}_RIGHT diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdout new file mode 100644 index 00000000..195b1a22 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/001-run-first-only/stdout @@ -0,0 +1,2 @@ +might match_regex ${GLOBAL_TOKEN}_LEFT +might_not match_regex ${GLOBAL_TOKEN}_RIGHT diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/README.md new file mode 100644 index 00000000..5e7a59df --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/README.md @@ -0,0 +1,59 @@ +# 002-run-second-only + +*[spec > bonuses > separators > or](..) > 002-run-second-only* + +The purpose of this test is to check that the OR operator `||` makes the right command to be executed if the left one exits with an error status code. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 42 || ./write_on_stdout ${GLOBAL_TOKEN} + +``` + +### What is expected on standard output + +```bash +might match_regex "${GLOBAL_TOKEN}" + +``` + +### What is expected on error output + +```bash +might be_empty + +``` + +### What miscellaneous behaviors are expected + +```bash +might exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/description b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/description new file mode 100644 index 00000000..f8892296 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/description @@ -0,0 +1 @@ +The purpose of this test is to check that the OR operator `||` makes the right command to be executed if the left one exits with an error status code. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/misc b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/misc new file mode 100644 index 00000000..fd805999 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/misc @@ -0,0 +1 @@ +might exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stderr new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stderr @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdin new file mode 100644 index 00000000..fc0472c0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdin @@ -0,0 +1 @@ +./exit_with_status 42 || ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdout new file mode 100644 index 00000000..bbdd98ff --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/002-run-second-only/stdout @@ -0,0 +1 @@ +might match_regex "${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/README.md new file mode 100644 index 00000000..8e2d2f22 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/README.md @@ -0,0 +1,60 @@ +# 003-run-until-succeeding + +*[spec > bonuses > separators > or](..) > 003-run-until-succeeding* + +The purpose of this test is to check that using the OR separator `||` with chained commands results in the execution of all until the first succeed. The remaining commands are not executed. +### Shell commands that are sent to the standard entry + +```bash +./exit_with_status 1 || ./exit_with_status 2 || ./exit_with_status 3 || ./exit_with_status 4 || ./write_on_stdout ${GLOBAL_TOKEN}_FIRST || ./write_on_stdout ${GLOBAL_TOKEN}_SECOND + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "${GLOBAL_TOKEN}_FIRST" +expected_to_not match_regex "${GLOBAL_TOKEN}_SECOND" + +``` + +### What is expected on error output + +```bash +expected_to be_empty + +``` + +### What miscellaneous behaviors are expected + +```bash +expected_to exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/description b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/description new file mode 100644 index 00000000..960a362b --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/description @@ -0,0 +1 @@ +The purpose of this test is to check that using the OR separator `||` with chained commands results in the execution of all until the first succeed. The remaining commands are not executed. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/misc b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/misc new file mode 100644 index 00000000..fe5959b7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/misc @@ -0,0 +1 @@ +expected_to exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stderr new file mode 100644 index 00000000..93b97883 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stderr @@ -0,0 +1 @@ +expected_to be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdin new file mode 100644 index 00000000..0f675560 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdin @@ -0,0 +1 @@ +./exit_with_status 1 || ./exit_with_status 2 || ./exit_with_status 3 || ./exit_with_status 4 || ./write_on_stdout ${GLOBAL_TOKEN}_FIRST || ./write_on_stdout ${GLOBAL_TOKEN}_SECOND diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdout new file mode 100644 index 00000000..16c3d329 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/003-run-until-succeeding/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "${GLOBAL_TOKEN}_FIRST" +expected_to_not match_regex "${GLOBAL_TOKEN}_SECOND" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/README.md new file mode 100644 index 00000000..a3b10c36 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/README.md @@ -0,0 +1,8 @@ +# or + +*[spec > bonuses > separators](..) > or* + +* [001-run-first-only](./001-run-first-only) +* [002-run-second-only](./002-run-second-only) +* [003-run-until-succeeding](./003-run-until-succeeding) +* [errors](./errors) diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/README.md new file mode 100644 index 00000000..c0b32de0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/README.md @@ -0,0 +1,62 @@ +# 001-parse-error-at-beginning + +*[spec > bonuses > separators > or > errors](..) > 001-parse-error-at-beginning* + +Parsing test. +The purpose of this test is to check that the OR operator `||` must be placed after a valid command. +If not, the Shell should display an error and exit with an error status code. +### Shell commands that are sent to the standard entry + +```bash +|| ./write_on_stdout ${GLOBAL_TOKEN} + +``` + +### What is expected on standard output + +```bash +might be_empty + +``` + +### What is expected on error output + +```bash +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" + +``` + +### What miscellaneous behaviors are expected + +```bash +might_not exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/description b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/description new file mode 100644 index 00000000..d29fb8ad --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/description @@ -0,0 +1,3 @@ +Parsing test. +The purpose of this test is to check that the OR operator `||` must be placed after a valid command. +If not, the Shell should display an error and exit with an error status code. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/misc b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/misc new file mode 100644 index 00000000..c4b48f73 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/misc @@ -0,0 +1 @@ +might_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stderr new file mode 100644 index 00000000..19c209de --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stderr @@ -0,0 +1,2 @@ +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdin new file mode 100644 index 00000000..9dfc6dbd --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdin @@ -0,0 +1 @@ +|| ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdout new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/001-parse-error-at-beginning/stdout @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/README.md new file mode 100644 index 00000000..1edf6632 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/README.md @@ -0,0 +1,63 @@ +# 002-parse-error-too-much-symbol + +*[spec > bonuses > separators > or > errors](..) > 002-parse-error-too-much-symbol* + +Parsing test. +The purpose of this test is to check that using more than two pipe symbols `|` is detected as an error. +The Shell should display an error and exit with a error status code. +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ${GLOBAL_TOKEN} ||| ./write_on_stdout ${GLOBAL_TOKEN} + +``` + +### What is expected on standard output + +```bash +might be_empty + +``` + +### What is expected on error output + +```bash +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" + + +``` + +### What miscellaneous behaviors are expected + +```bash +might_not exit_with_status "0" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/description b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/description new file mode 100644 index 00000000..940ef752 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/description @@ -0,0 +1,3 @@ +Parsing test. +The purpose of this test is to check that using more than two pipe symbols `|` is detected as an error. +The Shell should display an error and exit with a error status code. diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/misc b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/misc new file mode 100644 index 00000000..c4b48f73 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/misc @@ -0,0 +1 @@ +might_not exit_with_status "0" diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stderr b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stderr new file mode 100644 index 00000000..a6382d38 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stderr @@ -0,0 +1,3 @@ +might_not be_empty +might match_regex "([Ss]yntax|[Pp]arse) error" + diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdin b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdin new file mode 100644 index 00000000..782254a3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdin @@ -0,0 +1 @@ +./write_on_stdout ${GLOBAL_TOKEN} ||| ./write_on_stdout ${GLOBAL_TOKEN} diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdout b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdout new file mode 100644 index 00000000..c0265b63 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/002-parse-error-too-much-symbol/stdout @@ -0,0 +1 @@ +might be_empty diff --git a/42sh/42ShellTester/spec/bonuses/separators/or/errors/README.md b/42sh/42ShellTester/spec/bonuses/separators/or/errors/README.md new file mode 100644 index 00000000..babe06e9 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/separators/or/errors/README.md @@ -0,0 +1,6 @@ +# errors + +*[spec > bonuses > separators > or](..) > errors* + +* [001-parse-error-at-beginning](./001-parse-error-at-beginning) +* [002-parse-error-too-much-symbol](./002-parse-error-too-much-symbol) diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/README.md new file mode 100644 index 00000000..f5f690c9 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/README.md @@ -0,0 +1,53 @@ +# 001-expanded-with-HOME-1 + +*[spec > bonuses > tilde-expansion](..) > 001-expanded-with-HOME-1* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable HOME. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~ + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~" +expected_to match_regex "^/${GLOBAL_TOKEN}$" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/description new file mode 100644 index 00000000..53e01191 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable HOME. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdin new file mode 100644 index 00000000..69307f14 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdin @@ -0,0 +1 @@ +./write_on_stdout ~ diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdout new file mode 100644 index 00000000..3c9d4ab8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/001-expanded-with-HOME-1/stdout @@ -0,0 +1,2 @@ +expected_to_not match_regex "~" +expected_to match_regex "^/${GLOBAL_TOKEN}$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/README.md new file mode 100644 index 00000000..9af192b8 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/README.md @@ -0,0 +1,53 @@ +# 002-expanded-with-HOME-2 + +*[spec > bonuses > tilde-expansion](..) > 002-expanded-with-HOME-2* + +The purpose of this test is to check that the symbol tilde `~` followed by the symbol slash `/` may be expanded with the environment variable HOME. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~/${GLOBAL_TOKEN}_SUBDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~" +expected_to match_regex "^/${GLOBAL_TOKEN}/${GLOBAL_TOKEN}_SUBDIRECTORY$" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/description new file mode 100644 index 00000000..2c601af5 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` followed by the symbol slash `/` may be expanded with the environment variable HOME. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdin new file mode 100644 index 00000000..b806e8d9 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdin @@ -0,0 +1 @@ +./write_on_stdout ~/${GLOBAL_TOKEN}_SUBDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdout new file mode 100644 index 00000000..ddeb1db3 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/002-expanded-with-HOME-2/stdout @@ -0,0 +1,2 @@ +expected_to_not match_regex "~" +expected_to match_regex "^/${GLOBAL_TOKEN}/${GLOBAL_TOKEN}_SUBDIRECTORY$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/README.md new file mode 100644 index 00000000..d591b379 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/README.md @@ -0,0 +1,54 @@ +# 003-expanded-with-PWD-1 + +*[spec > bonuses > tilde-expansion](..) > 003-expanded-with-PWD-1* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable PWD when followed by the symbol `+`. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~+ + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~[+]" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}$" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/description new file mode 100644 index 00000000..545ed856 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable PWD when followed by the symbol `+`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdin new file mode 100644 index 00000000..c2315545 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdin @@ -0,0 +1 @@ +./write_on_stdout ~+ diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdout new file mode 100644 index 00000000..ec00fafb --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/003-expanded-with-PWD-1/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "~[+]" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/README.md new file mode 100644 index 00000000..6f108a8a --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/README.md @@ -0,0 +1,54 @@ +# 004-expanded-with-PWD-2 + +*[spec > bonuses > tilde-expansion](..) > 004-expanded-with-PWD-2* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable PWD when followed by the symbol `+`. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~+/${GLOBAL_TOKEN}_SUBDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~+/${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]/${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_SUBDIRECTORY$" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/description new file mode 100644 index 00000000..545ed856 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable PWD when followed by the symbol `+`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdin new file mode 100644 index 00000000..019c6cf9 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdin @@ -0,0 +1 @@ +./write_on_stdout ~+/${GLOBAL_TOKEN}_SUBDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdout new file mode 100644 index 00000000..23a27406 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/004-expanded-with-PWD-2/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "~+/${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]/${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_SUBDIRECTORY$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/README.md new file mode 100644 index 00000000..8220f52e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/README.md @@ -0,0 +1,57 @@ +# 005-expanded-with-OLDPWD-1 + +*[spec > bonuses > tilde-expansion](..) > 005-expanded-with-OLDPWD-1* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable OLDPWD when followed by the symbol `+`. +### What is done before test + +```bash +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~- + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~-" +expected_to_not match_regex "/${GLOBAL_TOKEN}-" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}$" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/before_exec new file mode 100644 index 00000000..52fbb306 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/before_exec @@ -0,0 +1,3 @@ +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/description new file mode 100644 index 00000000..1cb05172 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable OLDPWD when followed by the symbol `+`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdin new file mode 100644 index 00000000..c9e75916 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdin @@ -0,0 +1,2 @@ +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~- diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdout new file mode 100644 index 00000000..ff80be6f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/005-expanded-with-OLDPWD-1/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "~-" +expected_to_not match_regex "/${GLOBAL_TOKEN}-" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/README.md new file mode 100644 index 00000000..de98ffb2 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/README.md @@ -0,0 +1,57 @@ +# 006-expanded-with-OLDPWD-2 + +*[spec > bonuses > tilde-expansion](..) > 006-expanded-with-OLDPWD-2* + +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable OLDPWD when followed by the symbol `+`. +### What is done before test + +```bash +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~-/${GLOBAL_TOKEN}_OTHERDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to_not match_regex "~-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to_not match_regex "/${GLOBAL_TOKEN}-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_OTHERDIRECTORY$" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/before_exec new file mode 100644 index 00000000..52fbb306 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/before_exec @@ -0,0 +1,3 @@ +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/description new file mode 100644 index 00000000..1cb05172 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be expanded with the environment variable OLDPWD when followed by the symbol `+`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdin new file mode 100644 index 00000000..76895961 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdin @@ -0,0 +1,2 @@ +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~-/${GLOBAL_TOKEN}_OTHERDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdout new file mode 100644 index 00000000..1dbf719e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/006-expanded-with-OLDPWD-2/stdout @@ -0,0 +1,3 @@ +expected_to_not match_regex "~-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to_not match_regex "/${GLOBAL_TOKEN}-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to match_regex "^${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_OTHERDIRECTORY$" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/README.md new file mode 100644 index 00000000..5c02470e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/README.md @@ -0,0 +1,11 @@ +# tilde-expansion + +*[spec > bonuses](..) > tilde-expansion* + +* [001-expanded-with-HOME-1](./001-expanded-with-HOME-1) +* [002-expanded-with-HOME-2](./002-expanded-with-HOME-2) +* [003-expanded-with-PWD-1](./003-expanded-with-PWD-1) +* [004-expanded-with-PWD-2](./004-expanded-with-PWD-2) +* [005-expanded-with-OLDPWD-1](./005-expanded-with-OLDPWD-1) +* [006-expanded-with-OLDPWD-2](./006-expanded-with-OLDPWD-2) +* [not-expanded](./not-expanded) diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/README.md new file mode 100644 index 00000000..04bc890e --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/README.md @@ -0,0 +1,53 @@ +# 001-not-expanded-with-HOME-1 + +*[spec > bonuses > tilde-expansion > not-expanded](..) > 001-not-expanded-with-HOME-1* + +The purpose of this test is to check that the symbol tilde `~` may be not expanded when not followed by an authorized symbol or user name. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~~ + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^~~$" +expected_to_not match_regex "/${GLOBAL_TOKEN}" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/description new file mode 100644 index 00000000..739f0907 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be not expanded when not followed by an authorized symbol or user name. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdin new file mode 100644 index 00000000..fd5167ce --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdin @@ -0,0 +1 @@ +./write_on_stdout ~~ diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdout new file mode 100644 index 00000000..3160a089 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/001-not-expanded-with-HOME-1/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "^~~$" +expected_to_not match_regex "/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/README.md new file mode 100644 index 00000000..a573acaf --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/README.md @@ -0,0 +1,53 @@ +# 002-not-expanded-with-HOME-2 + +*[spec > bonuses > tilde-expansion > not-expanded](..) > 002-not-expanded-with-HOME-2* + +The purpose of this test is to check that the symbol tilde `~` may be not expanded when not followed by an authorized symbol or user name. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~${GLOBAL_TOKEN}_UNKNOWNUSER + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^~${GLOBAL_TOKEN}_UNKNOWNUSER$" +expected_to_not match_regex "/${GLOBAL_TOKEN}${GLOBAL_TOKEN}_UNKNOWNUSER" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/description new file mode 100644 index 00000000..739f0907 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` may be not expanded when not followed by an authorized symbol or user name. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdin new file mode 100644 index 00000000..3c0b74c7 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdin @@ -0,0 +1 @@ +./write_on_stdout ~${GLOBAL_TOKEN}_UNKNOWNUSER diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdout new file mode 100644 index 00000000..9a73fcf0 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/002-not-expanded-with-HOME-2/stdout @@ -0,0 +1,2 @@ +expected_to match_regex "^~${GLOBAL_TOKEN}_UNKNOWNUSER$" +expected_to_not match_regex "/${GLOBAL_TOKEN}${GLOBAL_TOKEN}_UNKNOWNUSER" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/README.md new file mode 100644 index 00000000..4019717d --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/README.md @@ -0,0 +1,54 @@ +# 003-not-expanded-with-PWD + +*[spec > bonuses > tilde-expansion > not-expanded](..) > 003-not-expanded-with-PWD* + +The purpose of this test is to check that the symbol tilde `~` is not expanded with the environment variable PWD when not followed by the symbol `/`. +### What is done before test + +```bash +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +./write_on_stdout ~+${GLOBAL_TOKEN}_SUBDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^~[+]${GLOBAL_TOKEN}_SUBDIRECTORY$" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to_not match_regex "${GLOBAL_TMP_DIRECTORY}${GLOBAL_TOKEN}_SUBDIRECTORY" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/before_exec new file mode 100644 index 00000000..2f825443 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/before_exec @@ -0,0 +1 @@ +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/description new file mode 100644 index 00000000..832e877c --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` is not expanded with the environment variable PWD when not followed by the symbol `/`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdin new file mode 100644 index 00000000..f0cc2677 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdin @@ -0,0 +1 @@ +./write_on_stdout ~+${GLOBAL_TOKEN}_SUBDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdout new file mode 100644 index 00000000..53269842 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/003-not-expanded-with-PWD/stdout @@ -0,0 +1,3 @@ +expected_to match_regex "^~[+]${GLOBAL_TOKEN}_SUBDIRECTORY$" +expected_to_not match_regex "/${GLOBAL_TOKEN}[+]${GLOBAL_TOKEN}_SUBDIRECTORY" +expected_to_not match_regex "${GLOBAL_TMP_DIRECTORY}${GLOBAL_TOKEN}_SUBDIRECTORY" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/README.md new file mode 100644 index 00000000..c45e2a7f --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/README.md @@ -0,0 +1,57 @@ +# 004-not-expanded-with-OLDPWD + +*[spec > bonuses > tilde-expansion > not-expanded](..) > 004-not-expanded-with-OLDPWD* + +The purpose of this test is to check that the symbol tilde `~` is not expanded with the environment variable OLDPWD when not followed by the symbol `/`. +### What is done before test + +```bash +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" + +``` + +### Shell commands that are sent to the standard entry + +```bash +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~-${GLOBAL_TOKEN}_OTHERDIRECTORY + +``` + +### What is expected on standard output + +```bash +expected_to match_regex "^~-${GLOBAL_TOKEN}_OTHERDIRECTORY$" +expected_to_not match_regex "/${GLOBAL_TOKEN}-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to_not match_regex "${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_OTHERDIRECTORY" + +``` + +### Variables + +The following variables may appear in this test: + +* ${**GLOBAL_INSTALLDIR**} -> The installation directory of 42ShellTester +* ${**GLOBAL_TMP_DIRECTORY**} -> The temporary directory in which tests are executed +* ${**GLOBAL_TOKEN**} -> A token that changes value at launch time +* ${**PATH**} -> The standard environment variable PATH +* ${**HOME**} -> The standard environment variable HOME + +### Support binaries + +The following binaries may appear in this test: + + +* **[./display_env](http://github.com/we-sh/42ShellTester/tree/master/support/display-env)** -> A binary that iterates on `**envp` and write each element on standard output. +* **[./display_program_name](http://github.com/we-sh/42ShellTester/tree/master/support/display-program-name)** -> A binary that writes its name on standard ouput. +* **[./display_pwd](http://github.com/we-sh/42ShellTester/tree/master/support/display-pwd)** -> A binary that writes on standard output the absolute path of the current directory returned by `getcwd(3)`, encountered with the strings `PWD:` and `:PWD`. +* **[./exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/exit-with-status)** -> A binary that immediately exits with the status given as first argument. +* **[./read_on_stdin](http://github.com/we-sh/42ShellTester/tree/master/support/read-on-stdin)** -> A binary that reads on standard entry and write each line on standard output suffixed with the character `@` (e.g. same behavior as `cat -e` and the *newline* character). When `read(2)` returns `-1`, then the string `STDIN READ ERROR` is written on standard error. +* **[./sleep_and_exit_with_status](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-exit-with-status)** -> A binary that sleeps for a duration in seconds given as first argument and then exits with status given as second argument. +* **[./sleep_and_write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/sleep-and-write-on-stderr)** -> A binary that sleeps for a duration in seconds given as first argument and then writes on STDERR the string given as second argument without EOL. +* **[./write_all_arguments_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-all-arguments-on-stdout)** -> A binary that writes on standard output each argument separated by the symbol `@`. If no argument is given, it writes the string "nothing to be written on stdout". +* **[./write_on_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stderr)** -> A binary that writes on standard error the first given argument (the same behavior as `echo` but with only one argument) and exits with an error status code given as second argument. If no argument is given, it writes the string "write on stderr" and exit with status `1`. +* **[./write_on_stdout](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout)** -> A binary that writes on standard output the first given argument (the same behavior as `echo` but with only one argument). If no argument is given, it writes the string "write on stdout". +* **[./write_on_stdout_and_stderr](http://github.com/we-sh/42ShellTester/tree/master/support/write-on-stdout-and-stderr)** -> A binary that writes on standard output the first given argument, and writes on standard error the second given argument. If an argument is missing, it writes the strings "write on stdout" and "write on stderr". diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/before_exec b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/before_exec new file mode 100644 index 00000000..52fbb306 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/before_exec @@ -0,0 +1,3 @@ +rm -rf "./${GLOBAL_TOKEN}_SUBDIRECTORY" +mkdir "./${GLOBAL_TOKEN}_SUBDIRECTORY" +export "HOME=/${GLOBAL_TOKEN}" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/description b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/description new file mode 100644 index 00000000..fad1aead --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/description @@ -0,0 +1 @@ +The purpose of this test is to check that the symbol tilde `~` is not expanded with the environment variable OLDPWD when not followed by the symbol `/`. diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdin b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdin new file mode 100644 index 00000000..4c3cec62 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdin @@ -0,0 +1,2 @@ +cd ./${GLOBAL_TOKEN}_SUBDIRECTORY +${GLOBAL_TMP_DIRECTORY}/write_on_stdout ~-${GLOBAL_TOKEN}_OTHERDIRECTORY diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdout b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdout new file mode 100644 index 00000000..1ed88c70 --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/004-not-expanded-with-OLDPWD/stdout @@ -0,0 +1,3 @@ +expected_to match_regex "^~-${GLOBAL_TOKEN}_OTHERDIRECTORY$" +expected_to_not match_regex "/${GLOBAL_TOKEN}-/${GLOBAL_TOKEN}_OTHERDIRECTORY" +expected_to_not match_regex "${GLOBAL_TMP_DIRECTORY}/${GLOBAL_TOKEN}_OTHERDIRECTORY" diff --git a/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/README.md b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/README.md new file mode 100644 index 00000000..bdb7eabc --- /dev/null +++ b/42sh/42ShellTester/spec/bonuses/tilde-expansion/not-expanded/README.md @@ -0,0 +1,8 @@ +# not-expanded + +*[spec > bonuses > tilde-expansion](..) > not-expanded* + +* [001-not-expanded-with-HOME-1](./001-not-expanded-with-HOME-1) +* [002-not-expanded-with-HOME-2](./002-not-expanded-with-HOME-2) +* [003-not-expanded-with-PWD](./003-not-expanded-with-PWD) +* [004-not-expanded-with-OLDPWD](./004-not-expanded-with-OLDPWD) diff --git a/42sh/another_file b/42sh/another_file new file mode 100644 index 00000000..4caf053f --- /dev/null +++ b/42sh/another_file @@ -0,0 +1,243 @@ +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_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/jobc_init.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_fds.c$$ +src/main/shell_init.c$$ +src/main/shell_sig.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..72a3d290 --- /dev/null +++ b/42sh/file @@ -0,0 +1,19 @@ +/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 +update_makefile.sh diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index 0af3c493..0e25ac2f 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/22 17:22:51 by ariard #+# #+# */ -/* Updated: 2017/03/23 00:32:27 by ariard ### ########.fr */ +/* Updated: 2017/03/29 13:29:26 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/types.h b/42sh/includes/types.h index ddd2fe13..26937100 100644 --- a/42sh/includes/types.h +++ b/42sh/includes/types.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */ -/* Updated: 2017/03/24 17:10:56 by ariard ### ########.fr */ +/* Updated: 2017/03/29 13:59:26 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -182,8 +182,6 @@ enum e_sym PIPE_CLOSE_SEQUENCE, CMD_SUPERIOR, SEQUENCE, - AND_OR_MAJOR, - AND_OR_MINOR, END_COMMAND, CONDITION, COMPLETE_CONDITION, diff --git a/42sh/libft/src/str/ft_strtok.c b/42sh/libft/src/str/ft_strtok.c index dbb73ed9..f051737d 100644 --- a/42sh/libft/src/str/ft_strtok.c +++ b/42sh/libft/src/str/ft_strtok.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 18:08:31 by jhalford #+# #+# */ -/* Updated: 2017/03/22 22:23:33 by wescande ### ########.fr */ +/* Updated: 2017/03/29 14:48:09 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,11 +14,15 @@ char *ft_strtok(char *s, const char *delim) { - static char *lasts; - int ch; + static char *lasts = NULL; + int ch; - if (s == 0) + if (!s) + { + if (!lasts) + return (NULL); s = lasts; + } if ((ch = *s++) == 0) return (0); while (ft_strchr(delim, ch)) diff --git a/42sh/sample/again.sh b/42sh/sample/again.sh index 1a85b88c..faaebbb4 100644 --- a/42sh/sample/again.sh +++ b/42sh/sample/again.sh @@ -1,2 +1,3 @@ echo "echo hello" >> sample/again.sh echo hello +echo hello diff --git a/42sh/sample/andor.sh b/42sh/sample/andor.sh index 76759a12..6d83ae1a 100644 --- a/42sh/sample/andor.sh +++ b/42sh/sample/andor.sh @@ -1,8 +1,8 @@ pwd > file && pwd >> file || ls | cat && ls | cat >> file || ls -cat -e file +cat -e file sleep 2 -echo "My sample :" +echo +echo "My script:" echo cat sample/andor.sh - diff --git a/42sh/sample/mix.sh b/42sh/sample/mix.sh index 9cfd3fc2..21b5a1dc 100644 --- a/42sh/sample/mix.sh +++ b/42sh/sample/mix.sh @@ -27,4 +27,4 @@ echo echo "My sample :" sleep 3 echo -cat sample/mix/mix.sh +cat sample/mix.sh diff --git a/42sh/src/builtin/bt_read_term.c b/42sh/src/builtin/bt_read_term.c index e8fa1eb4..5680eb6b 100644 --- a/42sh/src/builtin/bt_read_term.c +++ b/42sh/src/builtin/bt_read_term.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/25 16:02:05 by jhalford #+# #+# */ -/* Updated: 2017/03/25 04:20:00 by jhalford ### ########.fr */ +/* Updated: 2017/03/29 15:02:36 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,12 +28,9 @@ int bt_read_terminit(t_read *data) term = bt_read_term(1); if (!(data->flag & BT_READ_INTER)) return (0); - term.c_lflag = ECHO | ECHOE | ECHOK | ICANON; - term.c_lflag &= data->timeout ? ~ICANON : ~0; + term.c_lflag &= ~(ICANON | ECHO); term.c_cc[VTIME] = data->timeout * 10; term.c_cc[VMIN] = data->timeout ? 0 : 1; - if (data->flag & BT_READ_LS) - term.c_lflag &= ~ECHO; term.c_cc[VEOL] = data->delim; if (tcsetattr(0, TCSANOW, &term) < 0) { diff --git a/42sh/src/builtin/builtin_read.c b/42sh/src/builtin/builtin_read.c index 35743e5d..5b2d0495 100644 --- a/42sh/src/builtin/builtin_read.c +++ b/42sh/src/builtin/builtin_read.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */ -/* Updated: 2017/03/25 15:10:27 by jhalford ### ########.fr */ +/* Updated: 2017/03/29 15:19:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,14 +53,14 @@ int bt_read_loop(t_read *data) char buf[2]; esc = 0; - i = 0; - if (data->prompt && (data->flag & BT_READ_INTER)) - ft_printf(data->prompt); + if (!(i = 0) && data->prompt && (data->flag & BT_READ_INTER)) + ft_putstr(data->prompt); while (42) { - if ((ret = read(data->fd, buf, 1)) <= 0) + if ((ret = read(data->fd, buf, 4)) <= 0) return (ret); buf[ret] = 0; + ft_putchar(data->flag & BT_READ_LS ? 0 : *buf); if (!esc && *buf == data->delim) break ; esc = esc ? 0 : !(data->flag & BT_READ_LR) && (*buf == '\\'); @@ -89,11 +89,10 @@ int bt_read_assign(t_read *data) tok = ft_strtok(input, ifs); while (*names) { - if (!(builtin_setenv("setenv", (char*[]){"read", *names, tok}, NULL))) + if ((builtin_setenv("setenv", (char*[]){"read", *names, tok}, NULL))) return (1); - ifs = names[1] ? ifs : NULL; + ifs = (++names)[1] ? ifs : NULL; tok = ft_strtok(NULL, ifs); - names++; } return (0); } diff --git a/42sh/src/completion/c_match_glob.c b/42sh/src/completion/c_match_glob.c index 42be1d1e..8c01c1b7 100644 --- a/42sh/src/completion/c_match_glob.c +++ b/42sh/src/completion/c_match_glob.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 17:20:01 by gwojda #+# #+# */ -/* Updated: 2017/03/29 13:33:32 by gwojda ### ########.fr */ +/* Updated: 2017/03/29 15:25:41 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_case_branch.c b/42sh/src/exec/exec_case_branch.c index 84dc6208..3991cb23 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/27 15:05:49 by ariard ### ########.fr */ +/* Updated: 2017/03/29 12:22:56 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,8 @@ int exec_case_branch(t_btree **ast) t_exec *exec; exec = &data_singleton()->exec; - if (EXEC_IS_CASE_BRANCH(exec->attrs)) + if (EXEC_IS_CASE_BRANCH(exec->attrs) || !exec->case_pattern + || !*exec->case_pattern) return (0); node = (*ast)->item; av = token_to_argv(node->data.cmd.token, 1); diff --git a/42sh/src/glob/expand_bquote.c b/42sh/src/glob/expand_bquote.c index 5cdf4200..9b0f5bf5 100644 --- a/42sh/src/glob/expand_bquote.c +++ b/42sh/src/glob/expand_bquote.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/17 17:47:53 by wescande #+# #+# */ -/* Updated: 2017/03/23 03:20:10 by wescande ### ########.fr */ +/* Updated: 2017/03/29 14:59:17 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,7 +44,7 @@ static void init_expand(t_bquote *me, char *content, int doifs) char *content2; ifs = doifs ? ft_getenv(data_singleton()->local_var, "IFS") : NULL; - content = ft_strtok(content, ifs); + content = content ? ft_strtok(content, ifs) : content; if (!content || !(content2 = ft_strtok(NULL, ifs))) { ft_ld_pushfront(me->wk, gen_tab(ft_strjoinf(ft_strjoin(me->s1, content), @@ -83,9 +83,9 @@ static int search_bquote(t_bquote *me) me->mid = ft_strsub(sta, 1, me->str - sta - 1); me->s1 = ft_strsub(CH(*me->wk)[0], 0, sta - CH(*me->wk)[0]); me->s2 = ft_strdup(me->str + 1); - if ((content = get_output(me->mid))) - init_expand(me, content, - !is_char_esc(me->esc, CH(*me->wk)[0], sta)); + content = get_output(me->mid); + init_expand(me, content, + !is_char_esc(me->esc, CH(*me->wk)[0], sta)); ft_strdel(&me->mid); ft_strdel(&me->s1); ft_strdel(&me->s2); diff --git a/42sh/src/hash_table/is_hash.c b/42sh/src/hash_table/is_hash.c index 6c1dc818..09abc922 100644 --- a/42sh/src/hash_table/is_hash.c +++ b/42sh/src/hash_table/is_hash.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/18 11:08:40 by gwojda #+# #+# */ -/* Updated: 2017/03/29 11:05:34 by gwojda ### ########.fr */ +/* Updated: 2017/03/29 15:25:58 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/get_reserved_words.c b/42sh/src/lexer/get_reserved_words.c index 3bb8579d..382a6764 100644 --- a/42sh/src/lexer/get_reserved_words.c +++ b/42sh/src/lexer/get_reserved_words.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 00:07:05 by ariard #+# #+# */ -/* Updated: 2017/03/27 21:44:14 by gwojda ### ########.fr */ +/* Updated: 2017/03/29 15:07:16 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,7 +39,8 @@ static int recognization_rvwords(t_token *pv_tk, t_token *at_tk) || pv_tk->type == TK_ELIF || pv_tk->type == TK_ELSE || pv_tk->type == TK_DSEMI || pv_tk->type == TK_PAREN_OPEN || pv_tk->type == TK_LBRACE || pv_tk->type == TK_UNTIL) - || pv_tk->type == TK_PAREN_CLOSE + || pv_tk->type == TK_PAREN_CLOSE || pv_tk->type == TK_AND_IF + || pv_tk->type == TK_OR_IF || (pv_tk->type == TK_PAREN_CLOSE && at_tk->type == TK_PAREN_OPEN)); } diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index ea928af2..77242074 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/29 11:02:44 by gwojda ### ########.fr */ +/* Updated: 2017/03/29 15:27:46 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/aggregate_sym.c b/42sh/src/parser/aggregate_sym.c index 7fc190fd..5b36a3f8 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/27 17:23:36 by ariard ### ########.fr */ +/* Updated: 2017/03/29 15:19:50 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,6 +22,8 @@ static t_aggrematch g_aggrematch[] = {TK_DSEMI, CMD_SUPERIOR, CLOSE_LIST, TK_PAREN_CLOSE}, {TK_DSEMI, PIPE_SEMI_SEQUENCE, CLOSE_LIST, TK_PAREN_CLOSE}, {TK_DSEMI, PIPE_CLOSE_SEQUENCE, CLOSE_LIST, TK_PAREN_CLOSE}, + {TK_DSEMI, COMPOUND_LIST, CLOSE_LIST, TK_PAREN_CLOSE}, + {TK_DSEMI, COMPLETE_COMMANDS, CLOSE_LIST, TK_PAREN_CLOSE}, {TK_PAREN_OPEN, TK_IN, PATTERN_CASE, 0}, {TK_PAREN_OPEN, CASE_LIST_NS, PATTERN_CASE, 0}, {TK_PAREN_OPEN, CMD_SUPERIOR, OPEN_FUNC, 0}, @@ -31,11 +33,13 @@ static t_aggrematch g_aggrematch[] = {TK_PIPE, PIPE_CLOSE_SEQUENCE, SEQUENCE, PIPE_CLOSE_SEQUENCE}, {TK_FI, ELSE_PART, IF_CLAUSE, TK_IF}, {TK_FI, COMPOUND_LIST, IF_CLAUSE, COMPLETE_CONDITION}, + {TK_FI, COMPLETE_COMMANDS, IF_CLAUSE, COMPLETE_CONDITION}, {TK_FI, COMPLETE_CONDITION, IF_CLAUSE, COMPLETE_CONDITION}, {TK_FI, CONDITION, IF_CLAUSE, COMPLETE_CONDITION}, {TK_THEN, CONDITION, COMPLETE_CONDITION, CONDITION}, {TK_DONE, CMD_SUPERIOR, DO_GROUP, TK_DO}, {TK_DONE, COMPOUND_LIST, DO_GROUP, TK_DO}, + {TK_DONE, COMPLETE_COMMANDS, DO_GROUP, TK_DO}, {TK_ESAC, TK_IN, CASE_CLAUSE, TK_CASE}, {TK_ESAC, CASE_LIST_NS, CASE_CLAUSE, TK_CASE}, {TK_PAREN_CLOSE, SUBSHELL, SUBSHELL, TK_PAREN_OPEN}, @@ -51,12 +55,6 @@ static t_aggrematch g_aggrematch[] = {TK_RBRACE, PIPE_CLOSE_SEQUENCE, BRACE_CLAUSE, TK_LBRACE}, {TK_RBRACE, COMPOUND_LIST, BRACE_CLAUSE, TK_LBRACE}, {TK_RBRACE, CMD_SUPERIOR, BRACE_CLAUSE, TK_LBRACE}, - {TK_AND_IF, CMD_SUPERIOR, AND_OR_MINOR, CMD_SUPERIOR}, - {TK_AND_IF, PIPE_CLOSE_SEQUENCE, AND_OR_MINOR, PIPE_CLOSE_SEQUENCE}, - {TK_AND_IF, PIPE_SEMI_SEQUENCE, AND_OR_MINOR, PIPE_SEMI_SEQUENCE}, - {TK_OR_IF, PIPE_SEMI_SEQUENCE, AND_OR_MINOR, PIPE_SEMI_SEQUENCE}, - {TK_OR_IF, CMD_SUPERIOR, AND_OR_MINOR, CMD_SUPERIOR}, - {TK_OR_IF, PIPE_CLOSE_SEQUENCE, AND_OR_MINOR, PIPE_CLOSE_SEQUENCE}, {SEPARATOR_OP, CMD_SUPERIOR, SEPARATOR, 0}, {SEPARATOR_OP, COMPOUND_LIST, SEPARATOR, 0}, {SEPARATOR_OP, CASE_LIST_NS, SEPARATOR, 0}, @@ -103,6 +101,7 @@ static t_aggrematch g_aggrematch[] = {NEWLINE_LIST, CASE_LIST_NS, SEPARATOR, 0}, {NEWLINE_LIST, COMPLETE_CONDITION, COMPLETE_CONDITION, COMPLETE_CONDITION}, {NEWLINE_LIST, CONDITION, CONDITION, CONDITION}, + {NEWLINE_LIST, AND_OR, AND_OR, AND_OR}, {NEWLINE_LIST, COMPLETE_COMMANDS, LINEBREAK, 0}, {NEWLINE_LIST, LINEBREAK, PROGRAM, LINEBREAK}, {NEWLINE_LIST, FOR_WORDLIST, SEQUENTIAL_SEP, 0}, @@ -195,7 +194,7 @@ static t_aggrematch g_aggrematch[] = {CMD_NAME, CONDITION, CMD_SUPERIOR, 0}, {CMD_NAME, TK_PIPE, CMD_SUPERIOR, 0}, {CMD_NAME, SEQUENCE, CMD_SUPERIOR, 0}, - {CMD_NAME, AND_OR_MAJOR, CMD_SUPERIOR, 0}, + {CMD_NAME, AND_OR, CMD_SUPERIOR, 0}, {CMD_SUPERIOR, SEQUENCE, PIPE_SEMI_SEQUENCE, SEQUENCE}, {SIMPLE_COMMAND, ALL, COMMAND, 0}, {DO_GROUP, NAME, FOR_CLAUSE, TK_FOR}, @@ -226,14 +225,6 @@ static t_aggrematch g_aggrematch[] = {SUBSHELL, ALL, COMPOUND_COMMAND, 0}, {BRACE_CLAUSE, ALL, COMPOUND_COMMAND, 0}, {COMPOUND_COMMAND, FUNC_NAME, COMMAND, FUNC_NAME}, - {AND_OR_MINOR, PIPE_SEMI_SEQUENCE, AND_OR_MAJOR, PIPE_SEMI_SEQUENCE}, - {AND_OR_MINOR, PIPE_CLOSE_SEQUENCE, AND_OR_MAJOR, PIPE_CLOSE_SEQUENCE}, - {AND_OR_MINOR, LINEBREAK, AND_OR_MAJOR, 0}, - {AND_OR_MINOR, TK_PAREN_OPEN, AND_OR_MAJOR, 0}, - {AND_OR_MINOR, TK_LBRACE, AND_OR_MAJOR, 0}, - {AND_OR_MINOR, COMPLETE_COMMANDS, AND_OR_MAJOR, 0}, - {AND_OR_MINOR, AND_OR_MAJOR, AND_OR_MAJOR, 0}, - {AND_OR_MINOR, TK_BANG, AND_OR_MAJOR, TK_BANG}, {COMMAND, SEQUENCE, PIPE_SEMI_SEQUENCE, 0}, {COMMAND, COMPOUND_LIST, PIPE_SEMI_SEQUENCE, 0}, {COMMAND, CASE_LIST_NS, PIPE_SEMI_SEQUENCE, 0}, @@ -253,7 +244,7 @@ static t_aggrematch g_aggrematch[] = {COMMAND, TK_PAREN_OPEN, PIPE_SEMI_SEQUENCE, 0}, {COMMAND, TK_LBRACE, PIPE_SEMI_SEQUENCE, 0}, {COMMAND, COMPLETE_COMMANDS, PIPE_SEMI_SEQUENCE, 0}, - {COMMAND, AND_OR_MAJOR, PIPE_SEMI_SEQUENCE, 0}, + {COMMAND, AND_OR, PIPE_SEMI_SEQUENCE, 0}, {COMMAND, COMPLETE_CONDITION, PIPE_SEMI_SEQUENCE, 0}, {COMMAND, CONDITION, PIPE_SEMI_SEQUENCE, 0}, {COMPOUND_COMMAND, SEQUENCE, PIPE_CLOSE_SEQUENCE, 0}, @@ -275,12 +266,11 @@ static t_aggrematch g_aggrematch[] = {COMPOUND_COMMAND, TK_PAREN_OPEN, PIPE_CLOSE_SEQUENCE, 0}, {COMPOUND_COMMAND, TK_LBRACE, PIPE_CLOSE_SEQUENCE, 0}, {COMPOUND_COMMAND, COMPLETE_COMMANDS, PIPE_CLOSE_SEQUENCE, 0}, - {COMPOUND_COMMAND, AND_OR_MAJOR, PIPE_CLOSE_SEQUENCE, 0}, + {COMPOUND_COMMAND, AND_OR, PIPE_CLOSE_SEQUENCE, 0}, {COMPOUND_COMMAND, COMPLETE_CONDITION, PIPE_CLOSE_SEQUENCE, 0}, {COMPOUND_COMMAND, CONDITION, PIPE_CLOSE_SEQUENCE, 0}, {END_COMMAND, SEQUENCE, PIPE_SEQUENCE, SEQUENCE}, {END_COMMAND, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE}, - {END_COMMAND, AND_OR_MAJOR, LIST, AND_OR_MAJOR}, {END_COMMAND, TK_WHILE, PIPE_SEQUENCE, 0}, {END_COMMAND, TK_WHILE, PIPE_SEQUENCE, 0}, {END_COMMAND, TK_UNTIL, PIPE_SEQUENCE, 0}, @@ -299,6 +289,7 @@ static t_aggrematch g_aggrematch[] = {END_COMMAND, CONDITION, PIPE_SEQUENCE, 0}, {END_COMMAND, COMPOUND_LIST, COMPOUND_LIST, COMPOUND_LIST}, {END_COMMAND, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS}, + {END_COMMAND, AND_OR, COMPLETE_COMMANDS, 0}, {PIPE_SEMI_SEQUENCE, SEQUENCE, PIPE_SEMI_SEQUENCE, SEQUENCE}, {PIPE_CLOSE_SEQUENCE, SEQUENCE, PIPE_CLOSE_SEQUENCE, SEQUENCE}, {PIPE_SEQUENCE, TK_WHILE, PIPELINE, 0}, @@ -310,7 +301,7 @@ static t_aggrematch g_aggrematch[] = {PIPE_SEQUENCE, TK_PAREN_OPEN, PIPELINE, 0}, {PIPE_SEQUENCE, TK_LBRACE, PIPELINE, 0}, {PIPE_SEQUENCE, COMPLETE_COMMANDS, PIPELINE, 0}, - {PIPE_SEQUENCE, AND_OR_MAJOR, PIPELINE, 0}, + {PIPE_SEQUENCE, AND_OR, PIPELINE, 0}, {PIPE_SEQUENCE, TK_DO, PIPELINE, 0}, {PIPE_SEQUENCE, TK_PAREN_CLOSE, PIPELINE, 0}, {PIPE_SEQUENCE, TK_IF, PIPELINE, 0}, @@ -340,8 +331,8 @@ static t_aggrematch g_aggrematch[] = {PIPELINE, SEPARATOR_OP, AND_OR, 0}, {PIPELINE, COMPLETE_CONDITION, AND_OR, 0}, {PIPELINE, CONDITION, AND_OR, 0}, - {PIPELINE, AND_OR_MAJOR, AND_OR, AND_OR_MAJOR}, - {AND_OR_MAJOR, AND_OR_MAJOR, AND_OR_MAJOR, AND_OR_MAJOR}, + {PIPELINE, AND_OR, COMPLETE_COMMANDS, 0}, + {AND_OR, AND_OR, AND_OR, AND_OR}, {AND_OR, TK_DO, COMPOUND_LIST, 0}, {AND_OR, TK_PAREN_CLOSE, COMPOUND_LIST, 0}, {AND_OR, TK_WHILE, COMPOUND_LIST, 0}, diff --git a/42sh/src/parser/build_tree.c b/42sh/src/parser/build_tree.c index 1ebb2189..267dffc4 100644 --- a/42sh/src/parser/build_tree.c +++ b/42sh/src/parser/build_tree.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 18:32:59 by ariard #+# #+# */ -/* Updated: 2017/03/24 17:02:43 by ariard ### ########.fr */ +/* Updated: 2017/03/29 13:28:38 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/eval_sym.c b/42sh/src/parser/eval_sym.c index e7b153d3..2008c214 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/27 21:03:04 by ariard ### ########.fr */ +/* Updated: 2017/03/29 15:19:03 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ static t_stackmatch g_stackmatch[] = { {TK_WORD, CMD_SUFFIX}, {TK_WORD, TK_PIPE}, + {TK_WORD, AND_OR}, {TK_WORD, TK_CASE}, {TK_WORD, WORDLIST}, {TK_WORD, LINEBREAK}, @@ -37,12 +38,12 @@ static t_stackmatch g_stackmatch[] = {TK_IO_NUMBER, TK_LBRACE}, {TK_IO_NUMBER, COMPLETE_COMMANDS}, {TK_IO_NUMBER, SEPARATOR_OP}, + {TK_IO_NUMBER, AND_OR}, {TK_IO_NUMBER, NEWLINE_LIST}, {TK_IO_NUMBER, PIPE_SEMI_SEQUENCE}, {TK_IO_NUMBER, PIPE_CLOSE_SEQUENCE}, {TK_IO_NUMBER, SEQUENCE}, {TK_IO_NUMBER, CMD_SUPERIOR}, - {TK_IO_NUMBER, AND_OR_MAJOR}, {TK_IO_NUMBER, TK_WHILE}, {TK_IO_NUMBER, TK_UNTIL}, {TK_IO_NUMBER, TK_IF}, @@ -83,12 +84,12 @@ static t_stackmatch g_stackmatch[] = {TK_LESS, COMPLETE_COMMANDS}, {TK_LESS, TK_BANG}, {TK_LESS, SEPARATOR_OP}, + {TK_LESS, AND_OR}, {TK_LESS, NEWLINE_LIST}, {TK_LESS, PIPE_SEMI_SEQUENCE}, {TK_LESS, PIPE_CLOSE_SEQUENCE}, {TK_LESS, SEQUENCE}, {TK_LESS, CMD_SUPERIOR}, - {TK_LESS, AND_OR_MAJOR}, {TK_LESS, TK_WHILE}, {TK_LESS, TK_UNTIL}, {TK_LESS, TK_IF}, @@ -100,7 +101,6 @@ static t_stackmatch g_stackmatch[] = {TK_LESS, CONDITION}, {TK_LESS, COMPOUND_LIST}, {TK_LESS, CMD_SUPERIOR}, - {TK_LESS, AND_OR_MAJOR}, {TK_GREAT, TK_IO_NUMBER}, {TK_GREAT, REDIRECT_LIST}, {TK_GREAT, CMD_SUFFIX}, @@ -113,12 +113,12 @@ static t_stackmatch g_stackmatch[] = {TK_GREAT, TK_LBRACE}, {TK_GREAT, COMPLETE_COMMANDS}, {TK_GREAT, SEPARATOR_OP}, + {TK_GREAT, AND_OR}, {TK_GREAT, NEWLINE_LIST}, {TK_GREAT, PIPE_SEMI_SEQUENCE}, {TK_GREAT, PIPE_CLOSE_SEQUENCE}, {TK_GREAT, SEQUENCE}, {TK_GREAT, CMD_SUPERIOR}, - {TK_GREAT, AND_OR_MAJOR}, {TK_GREAT, TK_WHILE}, {TK_GREAT, TK_UNTIL}, {TK_GREAT, TK_IF}, @@ -130,7 +130,6 @@ static t_stackmatch g_stackmatch[] = {TK_GREAT, CONDITION}, {TK_GREAT, COMPOUND_LIST}, {TK_GREAT, CMD_SUPERIOR}, - {TK_GREAT, AND_OR_MAJOR}, {TK_DLESS, TK_IO_NUMBER}, {TK_DLESS, REDIRECT_LIST}, {TK_DLESS, CMD_SUFFIX}, @@ -143,12 +142,12 @@ static t_stackmatch g_stackmatch[] = {TK_DLESS, COMPLETE_COMMANDS}, {TK_DLESS, TK_BANG}, {TK_DLESS, SEPARATOR_OP}, + {TK_DLESS, AND_OR}, {TK_DLESS, NEWLINE_LIST}, {TK_DLESS, PIPE_SEMI_SEQUENCE}, {TK_DLESS, PIPE_CLOSE_SEQUENCE}, {TK_DLESS, SEQUENCE}, {TK_DLESS, CMD_SUPERIOR}, - {TK_DLESS, AND_OR_MAJOR}, {TK_DLESS, TK_WHILE}, {TK_DLESS, TK_UNTIL}, {TK_DLESS, TK_IF}, @@ -160,7 +159,6 @@ static t_stackmatch g_stackmatch[] = {TK_DLESS, CONDITION}, {TK_DLESS, COMPOUND_LIST}, {TK_DLESS, CMD_SUPERIOR}, - {TK_DLESS, AND_OR_MAJOR}, {TK_DGREAT, TK_IO_NUMBER}, {TK_DGREAT, REDIRECT_LIST}, {TK_DGREAT, CMD_SUFFIX}, @@ -173,12 +171,12 @@ static t_stackmatch g_stackmatch[] = {TK_DGREAT, TK_LBRACE}, {TK_DGREAT, COMPLETE_COMMANDS}, {TK_DGREAT, SEPARATOR_OP}, + {TK_DGREAT, AND_OR}, {TK_DGREAT, NEWLINE_LIST}, {TK_DGREAT, PIPE_SEMI_SEQUENCE}, {TK_DGREAT, PIPE_CLOSE_SEQUENCE}, {TK_DGREAT, SEQUENCE}, {TK_DGREAT, CMD_SUPERIOR}, - {TK_DGREAT, AND_OR_MAJOR}, {TK_DGREAT, TK_WHILE}, {TK_DGREAT, TK_UNTIL}, {TK_DGREAT, TK_IF}, @@ -190,7 +188,6 @@ static t_stackmatch g_stackmatch[] = {TK_DGREAT, CONDITION}, {TK_DGREAT, COMPOUND_LIST}, {TK_DGREAT, CMD_SUPERIOR}, - {TK_DGREAT, AND_OR_MAJOR}, {TK_LESSAND, TK_IO_NUMBER}, {TK_LESSAND, REDIRECT_LIST}, {TK_LESSAND, CMD_SUFFIX}, @@ -203,12 +200,12 @@ static t_stackmatch g_stackmatch[] = {TK_LESSAND, TK_LBRACE}, {TK_LESSAND, COMPLETE_COMMANDS}, {TK_LESSAND, SEPARATOR_OP}, + {TK_LESSAND, AND_OR}, {TK_LESSAND, NEWLINE_LIST}, {TK_LESSAND, PIPE_SEMI_SEQUENCE}, {TK_LESSAND, PIPE_CLOSE_SEQUENCE}, {TK_LESSAND, SEQUENCE}, {TK_LESSAND, CMD_SUPERIOR}, - {TK_LESSAND, AND_OR_MAJOR}, {TK_LESSAND, TK_WHILE}, {TK_LESSAND, TK_UNTIL}, {TK_LESSAND, TK_IF}, @@ -220,7 +217,6 @@ static t_stackmatch g_stackmatch[] = {TK_LESSAND, CONDITION}, {TK_LESSAND, COMPOUND_LIST}, {TK_LESSAND, CMD_SUPERIOR}, - {TK_LESSAND, AND_OR_MAJOR}, {TK_GREATAND, TK_IO_NUMBER}, {TK_GREATAND, REDIRECT_LIST}, {TK_GREATAND, CMD_SUFFIX}, @@ -233,12 +229,12 @@ static t_stackmatch g_stackmatch[] = {TK_GREATAND, TK_LBRACE}, {TK_GREATAND, COMPLETE_COMMANDS}, {TK_GREATAND, SEPARATOR_OP}, + {TK_GREATAND, AND_OR}, {TK_GREATAND, NEWLINE_LIST}, {TK_GREATAND, PIPE_SEMI_SEQUENCE}, {TK_GREATAND, PIPE_CLOSE_SEQUENCE}, {TK_GREATAND, SEQUENCE}, {TK_GREATAND, CMD_SUPERIOR}, - {TK_GREATAND, AND_OR_MAJOR}, {TK_GREATAND, TK_WHILE}, {TK_GREATAND, TK_UNTIL}, {TK_GREATAND, TK_IF}, @@ -250,7 +246,6 @@ static t_stackmatch g_stackmatch[] = {TK_GREATAND, CONDITION}, {TK_GREATAND, COMPOUND_LIST}, {TK_GREATAND, CMD_SUPERIOR}, - {TK_GREATAND, AND_OR_MAJOR}, {TK_IF, LINEBREAK}, {TK_IF, TK_BANG}, {TK_IF, TK_PAREN_OPEN}, @@ -258,6 +253,7 @@ static t_stackmatch g_stackmatch[] = {TK_IF, FUNC_NAME}, {TK_IF, COMPLETE_COMMANDS}, {TK_IF, SEPARATOR_OP}, + {TK_IF, AND_OR}, {TK_IF, NEWLINE_LIST}, {TK_IF, SEQUENCE}, {TK_IF, TK_WHILE}, @@ -286,13 +282,15 @@ static t_stackmatch g_stackmatch[] = {TK_FI, CMD_SUPERIOR}, {TK_FI, END_COMMAND}, {TK_FI, CONDITION}, - {TK_DO, CMD_SUPERIOR}, {TK_FI, COMPLETE_CONDITION}, + {TK_FI, COMPLETE_COMMANDS}, + {TK_DO, CMD_SUPERIOR}, {TK_DO, COMPOUND_LIST}, {TK_DO, NAME}, {TK_DO, SEQUENTIAL_SEP}, {TK_DONE, CMD_SUPERIOR}, {TK_DONE, COMPOUND_LIST}, + {TK_DONE, COMPLETE_COMMANDS}, {TK_DONE, END_COMMAND}, {TK_CASE, LINEBREAK}, {TK_CASE, TK_BANG}, @@ -315,6 +313,7 @@ static t_stackmatch g_stackmatch[] = {TK_CASE, COMPOUND_LIST}, {TK_CASE, NEWLINE_LIST}, {TK_CASE, SEPARATOR_OP}, + {TK_CASE, AND_OR}, {TK_CASE, SEQUENCE}, {TK_IN, TK_WORD}, {TK_IN, NAME}, @@ -328,6 +327,7 @@ static t_stackmatch g_stackmatch[] = {TK_WHILE, COMPLETE_COMMANDS}, {TK_WHILE, TK_BANG}, {TK_WHILE, SEPARATOR_OP}, + {TK_WHILE, AND_OR}, {TK_WHILE, NEWLINE_LIST}, {TK_WHILE, SEQUENCE}, {TK_WHILE, TK_DO}, @@ -350,6 +350,7 @@ static t_stackmatch g_stackmatch[] = {TK_UNTIL, COMPLETE_COMMANDS}, {TK_UNTIL, TK_BANG}, {TK_UNTIL, SEPARATOR_OP}, + {TK_UNTIL, AND_OR}, {TK_UNTIL, NEWLINE_LIST}, {TK_UNTIL, SEQUENCE}, {TK_UNTIL, TK_DO}, @@ -372,6 +373,7 @@ static t_stackmatch g_stackmatch[] = {FUNC_NAME, FUNC_NAME}, {FUNC_NAME, COMPLETE_COMMANDS}, {FUNC_NAME, SEPARATOR_OP}, + {FUNC_NAME, AND_OR}, {FUNC_NAME, NEWLINE_LIST}, {FUNC_NAME, SEQUENCE}, {FUNC_NAME, TK_WHILE}, @@ -394,6 +396,7 @@ static t_stackmatch g_stackmatch[] = {TK_FOR, FUNC_NAME}, {TK_FOR, COMPLETE_COMMANDS}, {TK_FOR, SEPARATOR_OP}, + {TK_FOR, AND_OR}, {TK_FOR, NEWLINE_LIST}, {TK_FOR, SEQUENCE}, {TK_FOR, TK_DO}, @@ -415,9 +418,9 @@ static t_stackmatch g_stackmatch[] = {TK_LBRACE, TK_LBRACE}, {TK_LBRACE, TK_PAREN_OPEN}, {TK_LBRACE, SEPARATOR_OP}, + {TK_LBRACE, AND_OR}, {TK_LBRACE, NEWLINE_LIST}, {TK_LBRACE, SEQUENCE}, - {TK_LBRACE, AND_OR_MAJOR}, {TK_LBRACE, TK_WHILE}, {TK_LBRACE, FUNC_NAME}, {TK_LBRACE, TK_UNTIL}, @@ -433,9 +436,11 @@ static t_stackmatch g_stackmatch[] = {TK_LBRACE, CONDITION}, {TK_LBRACE, TK_IN}, {TK_LBRACE, TK_PIPE}, + {TK_LBRACE, AND_OR}, {TK_RBRACE, TK_SEMI}, {TK_RBRACE, END_COMMAND}, {TK_RBRACE, SEPARATOR_OP}, + {TK_RBRACE, AND_OR}, {TK_RBRACE, WORD}, {TK_RBRACE, IN}, {TK_RBRACE, TK_AND_IF}, @@ -458,18 +463,20 @@ static t_stackmatch g_stackmatch[] = {TK_BANG, TK_LBRACE}, {TK_BANG, COMPLETE_COMMANDS}, {TK_BANG, SEPARATOR_OP}, + {TK_BANG, AND_OR}, {TK_BANG, NEWLINE_LIST}, {TK_IN, LINEBREAK}, {TK_SEMI, NAME}, {TK_SEMI, IN}, {TK_SEMI, WORDLIST}, {TK_SEMI, LIST}, - {TK_SEMI, TERM}, {TK_SEMI, CMD_NAME}, {TK_SEMI, PROGRAM}, {TK_SEMI, FOR_WORDLIST}, {TK_AMP, LIST}, {TK_AMP, TERM}, + {TK_AMP, PROGRAM}, + {TK_AMP, CMD_NAME}, {TK_PIPE, PATTERN}, {TK_PIPE, CMD_SUPERIOR}, {TK_PIPE, PIPE_SEMI_SEQUENCE}, @@ -481,10 +488,10 @@ static t_stackmatch g_stackmatch[] = {TK_PAREN_OPEN, TK_BANG}, {TK_PAREN_OPEN, TK_PAREN_OPEN}, {TK_PAREN_OPEN, SEPARATOR_OP}, + {TK_PAREN_OPEN, AND_OR}, {TK_PAREN_OPEN, NEWLINE_LIST}, {TK_PAREN_OPEN, SEQUENCE}, {TK_PAREN_OPEN, FUNC_NAME}, - {TK_PAREN_OPEN, AND_OR_MAJOR}, {TK_PAREN_OPEN, TK_WHILE}, {TK_PAREN_OPEN, TK_LBRACE}, {TK_PAREN_OPEN, FUNC_NAME}, @@ -508,7 +515,6 @@ static t_stackmatch g_stackmatch[] = {SEQUENTIAL_SEP, FOR_WORDLIST}, {END_COMMAND, SEQUENCE}, {END_COMMAND, PIPE_SEMI_SEQUENCE}, - {END_COMMAND, AND_OR_MAJOR}, {END_COMMAND, TK_WHILE}, {END_COMMAND, FUNC_NAME}, {END_COMMAND, TK_UNTIL}, @@ -527,6 +533,7 @@ static t_stackmatch g_stackmatch[] = {END_COMMAND, CASE_LIST_NS}, {END_COMMAND, COMPLETE_CONDITION}, {END_COMMAND, CONDITION}, + {END_COMMAND, AND_OR}, {SEPARATOR, CMD_SUPERIOR}, {SEPARATOR, TERM}, {SEPARATOR, COMPOUND_LIST}, @@ -535,7 +542,6 @@ static t_stackmatch g_stackmatch[] = {SEPARATOR, PIPE_CLOSE_SEQUENCE}, {SEPARATOR_OP, CMD_SUPERIOR}, {SEPARATOR_OP, LIST}, - {SEPARATOR_OP, TERM}, {SEPARATOR_OP, CASE_LIST_NS}, {SEPARATOR_OP, COMPOUND_LIST}, {SEPARATOR_OP, PIPE_SEMI_SEQUENCE}, @@ -543,12 +549,12 @@ static t_stackmatch g_stackmatch[] = {LINEBREAK, TK_SEMI}, {LINEBREAK, END_COMMAND}, {LINEBREAK, SEPARATOR_OP}, + {LINEBREAK, AND_OR}, {LINEBREAK, TK_PAREN_CLOSE}, {LINEBREAK, WORD}, {LINEBREAK, IN}, - {LINEBREAK, TK_AND_IF}, - {LINEBREAK, TK_OR_IF}, {LINEBREAK, TK_PIPE}, + {LINEBREAK, AND_OR}, {LINEBREAK, LINEBREAK}, {LINEBREAK, TK_BANG}, {LINEBREAK, COMPLETE_COMMANDS}, @@ -563,6 +569,7 @@ static t_stackmatch g_stackmatch[] = {TK_PAREN_CLOSE, TK_SEMI}, {TK_PAREN_CLOSE, END_COMMAND}, {TK_PAREN_CLOSE, SEPARATOR_OP}, + {TK_PAREN_CLOSE, AND_OR}, {TK_PAREN_CLOSE, WORD}, {TK_PAREN_CLOSE, IN}, {TK_PAREN_CLOSE, TK_PIPE}, @@ -582,6 +589,7 @@ static t_stackmatch g_stackmatch[] = {TK_RBRACE, TK_SEMI}, {TK_RBRACE, END_COMMAND}, {TK_RBRACE, SEPARATOR_OP}, + {TK_RBRACE, AND_OR}, {TK_RBRACE, WORD}, {TK_RBRACE, IN}, {TK_RBRACE, TK_PIPE}, @@ -614,6 +622,7 @@ static t_stackmatch g_stackmatch[] = {NEWLINE_LIST, TK_ELSE}, {NEWLINE_LIST, CMD_NAME}, {NEWLINE_LIST, NEWLINE_LIST}, + {NEWLINE_LIST, AND_OR}, {NEWLINE_LIST, NAME}, {NEWLINE_LIST, IN}, {NEWLINE_LIST, WORDLIST}, @@ -645,12 +654,12 @@ static t_stackmatch g_stackmatch[] = {IO_HERE, TK_LBRACE}, {IO_HERE, COMPLETE_COMMANDS}, {IO_HERE, SEPARATOR_OP}, + {IO_HERE, AND_OR}, {IO_HERE, NEWLINE_LIST}, {IO_HERE, PIPE_SEMI_SEQUENCE}, {IO_HERE, PIPE_CLOSE_SEQUENCE}, {IO_HERE, SEQUENCE}, {IO_HERE, CMD_SUPERIOR}, - {IO_HERE, AND_OR_MAJOR}, {IO_HERE, TK_WHILE}, {IO_HERE, TK_UNTIL}, {IO_HERE, TK_IF}, @@ -679,12 +688,12 @@ static t_stackmatch g_stackmatch[] = {IO_FILE, TK_BANG}, {IO_FILE, COMPLETE_COMMANDS}, {IO_FILE, SEPARATOR_OP}, + {IO_FILE, AND_OR}, {IO_FILE, NEWLINE_LIST}, {IO_FILE, PIPE_SEMI_SEQUENCE}, {IO_FILE, PIPE_CLOSE_SEQUENCE}, {IO_FILE, SEQUENCE}, {IO_FILE, CMD_SUPERIOR}, - {IO_FILE, AND_OR_MAJOR}, {IO_FILE, TK_WHILE}, {IO_FILE, TK_UNTIL}, {IO_FILE, TK_IF}, @@ -707,12 +716,12 @@ static t_stackmatch g_stackmatch[] = {IO_REDIRECT, TK_LBRACE}, {IO_REDIRECT, COMPLETE_COMMANDS}, {IO_REDIRECT, SEPARATOR_OP}, + {IO_REDIRECT, AND_OR}, {IO_REDIRECT, NEWLINE_LIST}, {IO_REDIRECT, PIPE_SEMI_SEQUENCE}, {IO_REDIRECT, PIPE_CLOSE_SEQUENCE}, {IO_REDIRECT, SEQUENCE}, {IO_REDIRECT, CMD_SUPERIOR}, - {IO_REDIRECT, AND_OR_MAJOR}, {IO_REDIRECT, TK_WHILE}, {IO_REDIRECT, TK_UNTIL}, {IO_REDIRECT, TK_IF}, @@ -735,10 +744,10 @@ static t_stackmatch g_stackmatch[] = {CMD_PREFIX, COMPLETE_COMMANDS}, {CMD_PREFIX, TK_BANG}, {CMD_PREFIX, SEPARATOR_OP}, + {CMD_PREFIX, AND_OR}, {CMD_PREFIX, NEWLINE_LIST}, {CMD_PREFIX, SEQUENCE}, {CMD_PREFIX, CMD_SUPERIOR}, - {CMD_PREFIX, AND_OR_MAJOR}, {CMD_PREFIX, TK_WHILE}, {CMD_PREFIX, TK_UNTIL}, {CMD_PREFIX, TK_IF}, @@ -756,13 +765,12 @@ static t_stackmatch g_stackmatch[] = {CMD_NAME, TK_LBRACE}, {CMD_NAME, TK_BANG}, {CMD_NAME, SEPARATOR_OP}, + {CMD_NAME, AND_OR}, {CMD_NAME, NEWLINE_LIST}, {CMD_NAME, SEQUENCE}, {CMD_NAME, CMD_SUPERIOR}, - {CMD_NAME, AND_OR_MAJOR}, {CMD_NAME, CONDITION}, {CMD_NAME, COMPOUND_LIST}, - {CMD_NAME, AND_OR_MAJOR}, {CMD_NAME, TK_WHILE}, {CMD_NAME, FUNC_NAME}, {CMD_NAME, TK_UNTIL}, @@ -795,10 +803,10 @@ static t_stackmatch g_stackmatch[] = {CMD_SUPERIOR, COMPLETE_COMMANDS}, {CMD_SUPERIOR, TK_BANG}, {CMD_SUPERIOR, SEPARATOR_OP}, + {CMD_SUPERIOR, AND_OR}, {CMD_SUPERIOR, NEWLINE_LIST}, {CMD_SUPERIOR, TK_PIPE}, {CMD_SUPERIOR, SEQUENCE}, - {CMD_SUPERIOR, AND_OR_MAJOR}, {CLOSE_FUNC, CMD_SUPERIOR}, {CLOSE_FUNC, OPEN_FUNC}, {SIMPLE_COMMAND, TK_WHILE}, @@ -819,9 +827,9 @@ static t_stackmatch g_stackmatch[] = {SIMPLE_COMMAND, COMPLETE_COMMANDS}, {SIMPLE_COMMAND, TK_BANG}, {SIMPLE_COMMAND, SEPARATOR_OP}, + {SIMPLE_COMMAND, AND_OR}, {SIMPLE_COMMAND, NEWLINE_LIST}, {SIMPLE_COMMAND, SEQUENCE}, - {SIMPLE_COMMAND, AND_OR_MAJOR}, {DO_GROUP, CMD_SUPERIOR}, {DO_GROUP, COMPOUND_LIST}, {DO_GROUP, NAME}, @@ -854,8 +862,8 @@ static t_stackmatch g_stackmatch[] = {COMPLETE_CONDITION, CASE_LIST_NS}, {COMPLETE_CONDITION, TK_BANG}, {COMPLETE_CONDITION, SEPARATOR_OP}, + {COMPLETE_CONDITION, AND_OR}, {COMPLETE_CONDITION, NEWLINE_LIST}, - {COMPLETE_CONDITION, AND_OR_MAJOR}, {COMPLETE_CONDITION, CASE_LIST_NS}, {COMPLETE_CONDITION, FUNC_NAME}, {FNAME, LINEBREAK}, @@ -864,6 +872,7 @@ static t_stackmatch g_stackmatch[] = {FNAME, COMPLETE_COMMANDS}, {FNAME, TK_BANG}, {FNAME, SEPARATOR_OP}, + {FNAME, AND_OR}, {FNAME, NEWLINE_LIST}, {FNAME, SEQUENCE}, {FUNCTION_BODY, FUNC}, @@ -874,6 +883,7 @@ static t_stackmatch g_stackmatch[] = {FUNCTION_DEFINITION, COMPLETE_COMMANDS}, {FUNCTION_DEFINITION, TK_BANG}, {FUNCTION_DEFINITION, SEPARATOR_OP}, + {FUNCTION_DEFINITION, AND_OR}, {FUNCTION_DEFINITION, NEWLINE_LIST}, {FUNCTION_DEFINITION, SEQUENCE}, {UNTIL_CLAUSE, LINEBREAK}, @@ -883,6 +893,7 @@ static t_stackmatch g_stackmatch[] = {UNTIL_CLAUSE, COMPLETE_COMMANDS}, {UNTIL_CLAUSE, TK_BANG}, {UNTIL_CLAUSE, SEPARATOR_OP}, + {UNTIL_CLAUSE, AND_OR}, {UNTIL_CLAUSE, NEWLINE_LIST}, {UNTIL_CLAUSE, SEQUENCE}, {UNTIL_CLAUSE, TK_DO}, @@ -898,11 +909,11 @@ static t_stackmatch g_stackmatch[] = {UNTIL_CLAUSE, CASE_LIST_NS}, {UNTIL_CLAUSE, COMPLETE_CONDITION}, {UNTIL_CLAUSE, CONDITION}, - {UNTIL_CLAUSE, AND_OR_MAJOR}, {WHILE_CLAUSE, LINEBREAK}, {WHILE_CLAUSE, COMPLETE_COMMANDS}, {WHILE_CLAUSE, TK_BANG}, {WHILE_CLAUSE, SEPARATOR_OP}, + {WHILE_CLAUSE, AND_OR}, {WHILE_CLAUSE, NEWLINE_LIST}, {WHILE_CLAUSE, SEQUENCE}, {WHILE_CLAUSE, TK_DO}, @@ -920,7 +931,6 @@ static t_stackmatch g_stackmatch[] = {WHILE_CLAUSE, CASE_LIST_NS}, {WHILE_CLAUSE, COMPLETE_CONDITION}, {WHILE_CLAUSE, CONDITION}, - {WHILE_CLAUSE, AND_OR_MAJOR}, {IF_CLAUSE, LINEBREAK}, {IF_CLAUSE, TK_BANG}, {IF_CLAUSE, TK_PAREN_OPEN}, @@ -928,6 +938,7 @@ static t_stackmatch g_stackmatch[] = {IF_CLAUSE, FUNC_NAME}, {IF_CLAUSE, COMPLETE_COMMANDS}, {IF_CLAUSE, SEPARATOR_OP}, + {IF_CLAUSE, AND_OR}, {IF_CLAUSE, NEWLINE_LIST}, {IF_CLAUSE, SEQUENCE}, {IF_CLAUSE, TK_DO}, @@ -944,7 +955,6 @@ static t_stackmatch g_stackmatch[] = {IF_CLAUSE, COMPLETE_COMMAND}, {IF_CLAUSE, COMPLETE_CONDITION}, {IF_CLAUSE, CONDITION}, - {IF_CLAUSE, AND_OR_MAJOR}, {BRACE_CLAUSE, LINEBREAK}, {BRACE_CLAUSE, TK_PAREN_OPEN}, {BRACE_CLAUSE, TK_LBRACE}, @@ -952,6 +962,7 @@ static t_stackmatch g_stackmatch[] = {BRACE_CLAUSE, COMPLETE_COMMANDS}, {BRACE_CLAUSE, TK_BANG}, {BRACE_CLAUSE, SEPARATOR_OP}, + {BRACE_CLAUSE, AND_OR}, {BRACE_CLAUSE, NEWLINE_LIST}, {BRACE_CLAUSE, SEQUENCE}, {BRACE_CLAUSE, TK_DO}, @@ -968,7 +979,6 @@ static t_stackmatch g_stackmatch[] = {BRACE_CLAUSE, COMPLETE_COMMAND}, {BRACE_CLAUSE, COMPLETE_CONDITION}, {BRACE_CLAUSE, CONDITION}, - {BRACE_CLAUSE, AND_OR_MAJOR}, {PATTERN, PATTERN_CASE}, {PATTERN, CASE_LIST}, {PATTERN, TK_IN}, @@ -981,6 +991,7 @@ static t_stackmatch g_stackmatch[] = {CASE_CLAUSE, FUNC_NAME}, {CASE_CLAUSE, COMPLETE_COMMANDS}, {CASE_CLAUSE, SEPARATOR_OP}, + {CASE_CLAUSE, AND_OR}, {CASE_CLAUSE, NEWLINE_LIST}, {CASE_CLAUSE, SEQUENCE}, {CASE_CLAUSE, TK_PAREN_CLOSE}, @@ -997,7 +1008,6 @@ static t_stackmatch g_stackmatch[] = {CASE_CLAUSE, CASE_LIST_NS}, {CASE_CLAUSE, COMPLETE_CONDITION}, {CASE_CLAUSE, CONDITION}, - {CASE_CLAUSE, AND_OR_MAJOR}, {WORDLIST, IN}, {IN, LINEBREAK}, {NAME, TK_FOR}, @@ -1009,6 +1019,7 @@ static t_stackmatch g_stackmatch[] = {FOR_CLAUSE, FUNC_NAME}, {FOR_CLAUSE, COMPLETE_COMMANDS}, {FOR_CLAUSE, SEPARATOR_OP}, + {FOR_CLAUSE, AND_OR}, {FOR_CLAUSE, NEWLINE_LIST}, {FOR_CLAUSE, SEQUENCE}, {FOR_CLAUSE, TK_DO}, @@ -1024,7 +1035,6 @@ static t_stackmatch g_stackmatch[] = {FOR_CLAUSE, CASE_LIST_NS}, {FOR_CLAUSE, COMPLETE_CONDITION}, {FOR_CLAUSE, CONDITION}, - {FOR_CLAUSE, AND_OR_MAJOR}, {COMPOUND_LIST, TK_DO}, {COMPOUND_LIST, TK_PAREN_CLOSE}, {COMPOUND_LIST, TK_LBRACE}, @@ -1045,11 +1055,13 @@ static t_stackmatch g_stackmatch[] = {SUBSHELL, COMPLETE_COMMANDS}, {SUBSHELL, TK_BANG}, {SUBSHELL, SEPARATOR_OP}, + {SUBSHELL, AND_OR}, {SUBSHELL, NEWLINE_LIST}, {SUBSHELL, SEQUENCE}, {SUBSHELL, TK_LBRACE}, {SUBSHELL, TK_PAREN_OPEN}, {SUBSHELL, SEPARATOR_OP}, + {SUBSHELL, AND_OR}, {SUBSHELL, NEWLINE_LIST}, {SUBSHELL, TK_DO}, {SUBSHELL, TK_PAREN_CLOSE}, @@ -1064,13 +1076,13 @@ static t_stackmatch g_stackmatch[] = {SUBSHELL, CASE_LIST_NS}, {SUBSHELL, COMPLETE_CONDITION}, {SUBSHELL, CONDITION}, - {SUBSHELL, AND_OR_MAJOR}, {COMPOUND_COMMAND, LINEBREAK}, {COMPOUND_COMMAND, TK_PAREN_OPEN}, {COMPOUND_COMMAND, TK_LBRACE}, {COMPOUND_COMMAND, COMPLETE_COMMANDS}, {COMPOUND_COMMAND, TK_BANG}, {COMPOUND_COMMAND, SEPARATOR_OP}, + {COMPOUND_COMMAND, AND_OR}, {COMPOUND_COMMAND, NEWLINE_LIST}, {COMPOUND_COMMAND, SEQUENCE}, {COMPOUND_COMMAND, FUNC}, @@ -1087,7 +1099,6 @@ static t_stackmatch g_stackmatch[] = {COMPOUND_COMMAND, CASE_LIST_NS}, {COMPOUND_COMMAND, COMPLETE_CONDITION}, {COMPOUND_COMMAND, CONDITION}, - {COMPOUND_COMMAND, AND_OR_MAJOR}, {COMMAND, TK_WHILE}, {COMMAND, TK_UNTIL}, {COMMAND, LINEBREAK}, @@ -1106,16 +1117,9 @@ static t_stackmatch g_stackmatch[] = {COMMAND, COMPLETE_CONDITION}, {COMMAND, CONDITION}, {COMMAND, SEPARATOR_OP}, + {COMMAND, AND_OR}, {COMMAND, NEWLINE_LIST}, {COMMAND, SEQUENCE}, - {COMMAND, AND_OR_MAJOR}, - {AND_OR_MINOR, SEQUENCE}, - {AND_OR_MINOR, LINEBREAK}, - {AND_OR_MINOR, TK_BANG}, - {AND_OR_MINOR, TK_PAREN_OPEN}, - {AND_OR_MINOR, TK_LBRACE}, - {AND_OR_MINOR, COMPLETE_COMMANDS}, - {AND_OR_MINOR, AND_OR_MAJOR}, {PIPE_SEQUENCE, TK_WHILE}, {PIPE_SEQUENCE, FUNC_NAME}, {PIPE_SEQUENCE, TK_UNTIL}, @@ -1135,8 +1139,8 @@ static t_stackmatch g_stackmatch[] = {PIPE_SEQUENCE, TK_LBRACE}, {PIPE_SEQUENCE, COMPLETE_COMMANDS}, {PIPE_SEQUENCE, SEPARATOR_OP}, + {PIPE_SEQUENCE, AND_OR}, {PIPE_SEQUENCE, NEWLINE_LIST}, - {PIPE_SEQUENCE, AND_OR_MAJOR}, {TK_BANG, TK_WHILE}, {TK_BANG, TK_UNTIL}, {TK_BANG, TK_DO}, @@ -1154,8 +1158,8 @@ static t_stackmatch g_stackmatch[] = {TK_BANG, TK_LBRACE}, {TK_BANG, COMPLETE_COMMANDS}, {TK_BANG, SEPARATOR_OP}, + {TK_BANG, AND_OR}, {TK_BANG, NEWLINE_LIST}, - {TK_BANG, AND_OR_MAJOR}, {PIPE_SEMI_SEQUENCE, TK_WHILE}, {PIPE_SEMI_SEQUENCE, TK_UNTIL}, {PIPE_SEMI_SEQUENCE, TK_DO}, @@ -1174,8 +1178,8 @@ static t_stackmatch g_stackmatch[] = {PIPE_SEMI_SEQUENCE, TK_LBRACE}, {PIPE_SEMI_SEQUENCE, COMPLETE_COMMANDS}, {PIPE_SEMI_SEQUENCE, SEPARATOR_OP}, + {PIPE_SEMI_SEQUENCE, AND_OR}, {PIPE_SEMI_SEQUENCE, NEWLINE_LIST}, - {PIPE_SEMI_SEQUENCE, AND_OR_MAJOR}, {PIPE_SEMI_SEQUENCE, SEQUENCE}, {PIPE_CLOSE_SEQUENCE, TK_WHILE}, {PIPE_CLOSE_SEQUENCE, TK_UNTIL}, @@ -1195,8 +1199,8 @@ static t_stackmatch g_stackmatch[] = {PIPE_CLOSE_SEQUENCE, TK_LBRACE}, {PIPE_CLOSE_SEQUENCE, COMPLETE_COMMANDS}, {PIPE_CLOSE_SEQUENCE, SEPARATOR_OP}, + {PIPE_CLOSE_SEQUENCE, AND_OR}, {PIPE_CLOSE_SEQUENCE, NEWLINE_LIST}, - {PIPE_CLOSE_SEQUENCE, AND_OR_MAJOR}, {PIPE_CLOSE_SEQUENCE, SEQUENCE}, {SEQUENCE, PIPE_SEMI_SEQUENCE}, {SEQUENCE, PIPE_CLOSE_SEQUENCE}, @@ -1218,8 +1222,8 @@ static t_stackmatch g_stackmatch[] = {SEQUENCE, COMPLETE_COMMANDS}, {SEQUENCE, TK_BANG}, {SEQUENCE, SEPARATOR_OP}, + {SEQUENCE, AND_OR}, {SEQUENCE, NEWLINE_LIST}, - {SEQUENCE, AND_OR_MAJOR}, {SEQUENCE, SEQUENCE}, {PIPELINE, TK_WHILE}, {PIPELINE, TK_UNTIL}, @@ -1239,16 +1243,8 @@ static t_stackmatch g_stackmatch[] = {PIPELINE, TK_LBRACE}, {PIPELINE, COMPLETE_COMMANDS}, {PIPELINE, SEPARATOR_OP}, - {PIPELINE, SEPARATOR_OP}, + {PIPELINE, AND_OR}, {PIPELINE, NEWLINE_LIST}, - {PIPELINE, AND_OR_MAJOR}, - {AND_OR_MAJOR, LINEBREAK}, - {AND_OR_MAJOR, TK_BANG}, - {AND_OR_MAJOR, TK_PAREN_OPEN}, - {AND_OR_MAJOR, TK_LBRACE}, - {AND_OR_MAJOR, COMPLETE_COMMANDS}, - {AND_OR_MAJOR, AND_OR_MAJOR}, - {AND_OR_MAJOR, AND_OR_MAJOR}, {AND_OR, TK_DO}, {AND_OR, TK_PAREN_CLOSE}, {AND_OR, TK_WHILE}, @@ -1257,7 +1253,9 @@ static t_stackmatch g_stackmatch[] = {AND_OR, TK_ELIF}, {AND_OR, TK_THEN}, {AND_OR, TK_ELSE}, + {AND_OR, CMD_SUPERIOR}, {AND_OR, COMPOUND_LIST}, + {AND_OR, PIPE_SEMI_SEQUENCE}, {AND_OR, CASE_LIST_NS}, {AND_OR, COMPLETE_CONDITION}, {AND_OR, CONDITION}, @@ -1266,8 +1264,6 @@ static t_stackmatch g_stackmatch[] = {AND_OR, TK_PAREN_OPEN}, {AND_OR, TK_LBRACE}, {AND_OR, COMPLETE_COMMANDS}, - {AND_OR, SEPARATOR_OP}, - {AND_OR, SEPARATOR_OP}, {AND_OR, NEWLINE_LIST}, {LIST, LINEBREAK}, {LIST, COMPLETE_COMMANDS}, @@ -1289,6 +1285,7 @@ int eval_sym(t_list **stack, t_sym new_sym) return (1); head = (*stack)->content; i = 0; + DG("eval %s &7 %s", read_state(*head), read_state(new_sym)); while (g_stackmatch[i].top) { if (new_sym == g_stackmatch[i].top && *head == g_stackmatch[i].under) diff --git a/42sh/src/parser/ft_parse.c b/42sh/src/parser/ft_parse.c index eadf5383..9680e92a 100644 --- a/42sh/src/parser/ft_parse.c +++ b/42sh/src/parser/ft_parse.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/11 16:17:38 by ariard #+# #+# */ -/* Updated: 2017/03/25 15:48:25 by ariard ### ########.fr */ +/* Updated: 2017/03/29 15:24:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,6 +40,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser) while (parser && token && *token) { produce_sym(&parser->stack, parser->new_sym, token); + DG("produce sym %s", read_state(*parser->new_sym)); if (parser->new_sym && eval_sym(&parser->stack, *parser->new_sym)) return ((parser->state = ERROR)); if (aggregate_sym(&parser->stack, parser->new_sym, &parser->state)) diff --git a/42sh/src/parser/parser_destroy.c b/42sh/src/parser/parser_destroy.c index 0ca8ffcd..b81f302a 100644 --- a/42sh/src/parser/parser_destroy.c +++ b/42sh/src/parser/parser_destroy.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/16 19:30:17 by ariard #+# #+# */ -/* Updated: 2017/03/26 21:46:24 by jhalford ### ########.fr */ +/* Updated: 2017/03/29 13:29:01 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/parser_init.c b/42sh/src/parser/parser_init.c index e31e0e19..a61a4414 100644 --- a/42sh/src/parser/parser_init.c +++ b/42sh/src/parser/parser_init.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/21 16:14:04 by ariard #+# #+# */ -/* Updated: 2017/03/26 21:36:48 by jhalford ### ########.fr */ +/* Updated: 2017/03/29 13:27:45 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/produce_sym.c b/42sh/src/parser/produce_sym.c index 3a989fb5..58b1b97b 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/27 17:22:10 by ariard ### ########.fr */ +/* Updated: 2017/03/29 14:31:14 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,7 +31,6 @@ static t_prodmatch g_prodmatch[] = {TK_WORD, TK_BANG, CMD_NAME}, {TK_WORD, TK_PIPE, CMD_NAME}, {TK_WORD, AND_OR, CMD_NAME}, - {TK_WORD, AND_OR_MAJOR, CMD_NAME}, {TK_WORD, TK_PAREN_CLOSE, CMD_NAME}, {TK_WORD, TK_WHILE, CMD_NAME}, {TK_WORD, TK_UNTIL, CMD_NAME}, @@ -75,7 +74,6 @@ static t_prodmatch g_prodmatch[] = {TK_ASSIGNMENT_WORD, COMPLETE_CONDITION, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, CONDITION, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, AND_OR, CMD_PREFIX}, - {TK_ASSIGNMENT_WORD, AND_OR_MAJOR, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, PIPE_SEMI_SEQUENCE, CMD_SUFFIX}, {TK_ASSIGNMENT_WORD, SEQUENCE, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, COMPLETE_COMMANDS, CMD_PREFIX}, @@ -119,6 +117,7 @@ static t_prodmatch g_prodmatch[] = {TK_NEWLINE, CONDITION, NEWLINE_LIST}, {TK_NEWLINE, FOR_WORDLIST, NEWLINE_LIST}, {TK_NEWLINE, SEQUENTIAL_SEP, NEWLINE_LIST}, + {TK_NEWLINE, AND_OR, NEWLINE_LIST}, {TK_NEWLINE, PROGRAM, NEWLINE_LIST}, {TK_SEMI, CMD_SUPERIOR, SEPARATOR_OP}, {TK_SEMI, LIST, SEPARATOR_OP}, @@ -128,6 +127,8 @@ static t_prodmatch g_prodmatch[] = {TK_AMP, LIST, SEPARATOR_OP}, {TK_AMP, PIPE_SEMI_SEQUENCE, SEPARATOR_OP}, {TK_AMP, PIPE_CLOSE_SEQUENCE, SEPARATOR_OP}, + {TK_AND_IF, ALL, AND_OR}, + {TK_OR_IF, ALL, AND_OR}, {0, 0, 0}, }; @@ -146,7 +147,7 @@ int produce_sym(t_list **stack, t_sym *new_sym, t_list **lst) while (g_prodmatch[i].new_sym) { if (token->type == g_prodmatch[i].token - && *head == g_prodmatch[i].stack) + && (*head == g_prodmatch[i].stack || g_prodmatch[i].stack == ALL)) *new_sym = g_prodmatch[i].new_sym; i++; } diff --git a/42sh/src/parser/stack_init.c b/42sh/src/parser/stack_init.c index 67270a1c..2bdf8bef 100644 --- a/42sh/src/parser/stack_init.c +++ b/42sh/src/parser/stack_init.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/16 20:31:32 by ariard #+# #+# */ -/* Updated: 2017/03/26 21:47:01 by jhalford ### ########.fr */ +/* Updated: 2017/03/29 13:27:26 by ariard ### ########.fr */ /* */ /* ************************************************************************** */