diff --git a/unitests.sh b/unitests.sh index dd0bbda..a1b40f9 100644 --- a/unitests.sh +++ b/unitests.sh @@ -33,6 +33,7 @@ MINISHELL="../minishell" LINE_NUMBER=0 OPTION=0 PRINT=0 + FILES_BEFORE="$(ls .)" mkdir -p ./logs echo "" > ./logs/bash_log.txt echo "" > ./logs/minishell_log.txt @@ -89,6 +90,17 @@ MINISHELL="../minishell" echo "" } +# to delete the files created during the script + function delete_files + { + FILES_AFTER="$(ls .)" + DIFF_FILES="$(comm -3 <(echo "$FILES_BEFORE") <(echo "$FILES_AFTER"))" + while read line_diff + do + rm -r "$line_diff" + done < <(echo "$DIFF_FILES") + } + # check for arguments, like options or files list # if no file in arguments, default file list is used list_files="$default_files" @@ -98,7 +110,8 @@ MINISHELL="../minishell" if [ "$1" == "help" ] then print_usage - START=0 + delete_files + exit 0 elif [ "$1" == "-p1" ] then PRINT=1 @@ -272,8 +285,9 @@ MINISHELL="../minishell" fi # ask to show the diff - read -p 'you want to see the diff ? (y?)' DIFF - if [[ "${DIFF,,}" =~ y|yes ]] +# -rsn1 will stop read after first key pressed + read -rsn1 -p 'if you want to see the diff, press "y"' DIFF + if [[ "${DIFF,,}" == y ]] then diff -y --width=100 --color=always "$BASH_LOG" "$MINISHELL_LOG" fi