From b7ae8b79c9980dde23fe82a9771115532d296e08 Mon Sep 17 00:00:00 2001 From: Timo Schmidt Date: Fri, 31 Mar 2023 18:51:18 +0200 Subject: [PATCH] Error handlng --- .bashrc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.bashrc b/.bashrc index 16a0c98..cb054c8 100644 --- a/.bashrc +++ b/.bashrc @@ -149,11 +149,16 @@ timoulinette () { git_full="${git_base}/${subject}/${ex}/${test_file_name}" # Name of the C testfile - download_file_name="./timo_moulinette_${subject}_${ex}_${test_file_name}" + download_file_name="./timoulinette${subject}_${ex}_${test_file_name}" # Download tesfile curl -sL "${git_full}" -o "${download_file_name}" + if [ ! "${?}" = "1" ] ; then + printf '%s\n' "There's now testfile for this task, sorry!" + return + fi + # Preprocess source file (remove comments) ${CC} -dD -E -o "${file_name}.nocomments" -- "${file_name}" @@ -181,7 +186,7 @@ timoulinette () { guard_name="$(safe_guard_name "${macro}")" # Endif include guard - printf '%s\n' "#endif" | cat -- - "${download_file_name}" > ".tmpaddfirstlinefile.c" + printf '%s\n\n' "#endif" | cat -- - "${download_file_name}" > ".tmpaddfirstlinefile.c" mv -- ".tmpaddfirstlinefile.c" "${download_file_name}" # The macro itself @@ -199,7 +204,7 @@ timoulinette () { IFS="$(printf ' \n\t')" # Compile - out_binary="timo_moulinette_${subject}_${ex}_$(basename -- "${test_file_name}" .c).out" + out_binary="timoulinette${subject}_${ex}_$(basename -- "${test_file_name}" .c).out" ${CC} -Wall -Wextra -Werror -o "${out_binary}" -xc -- *.c err_code="${?}"