ajout un handler de sigint pour quitter proprement en cas de ctrl-c
This commit is contained in:
30
unitests.sh
30
unitests.sh
@@ -42,6 +42,25 @@ cd $(dirname $0)
|
|||||||
# copy the executable to current directory
|
# copy the executable to current directory
|
||||||
cp $MINISHELL .
|
cp $MINISHELL .
|
||||||
|
|
||||||
|
# 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 -r line_diff
|
||||||
|
do
|
||||||
|
rm -rf "$line_diff"
|
||||||
|
done < <(echo "$diff_files")
|
||||||
|
}
|
||||||
|
|
||||||
|
# handle sigint signal
|
||||||
|
function handler_sigint
|
||||||
|
{
|
||||||
|
delete_files
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
trap 'handler_sigint' 2
|
||||||
|
|
||||||
# default list of files to be use
|
# default list of files to be use
|
||||||
DEFAULT_FILES="$( find $DEFAULT_DIR | tail -n+2 )"
|
DEFAULT_FILES="$( find $DEFAULT_DIR | tail -n+2 )"
|
||||||
|
|
||||||
@@ -58,17 +77,6 @@ cd $(dirname $0)
|
|||||||
echo ""
|
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 -r line_diff
|
|
||||||
do
|
|
||||||
rm -rf "$line_diff"
|
|
||||||
done < <(echo "$diff_files")
|
|
||||||
}
|
|
||||||
|
|
||||||
# check for arguments, like options or files list
|
# check for arguments, like options or files list
|
||||||
# if no file in arguments, default file list is used
|
# if no file in arguments, default file list is used
|
||||||
function parse_arguments
|
function parse_arguments
|
||||||
|
|||||||
Reference in New Issue
Block a user