From 13ab4fa822e8b324e0cbb15dd70ee535b78f2538 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 22 Jan 2017 21:27:04 +0100 Subject: [PATCH] Nouveau helper ynh_check_path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nouveau helper pour vérifier et corriger la syntaxe du path. Et ça permet de passer le test "incorrect_path" de package check --- data/helpers.d/network | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 data/helpers.d/network diff --git a/data/helpers.d/network b/data/helpers.d/network new file mode 100644 index 000000000..59cb6faf5 --- /dev/null +++ b/data/helpers.d/network @@ -0,0 +1,15 @@ +# Check the path syntax +# Check the slash at the beginning of path and its absence at ending +# +# example: ynh_check_path +# +# usage: ynh_check_path +ynh_check_path () { + test -n "$path" || ynh_die "The path variable is empty." + if [ "${path:0:1}" != "/" ]; then # If the first character is a / + path="/$path" # Add / at begin of path variable + fi + if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # If the last character is a / and that not the only character. + path="${path:0:${#path}-1}" # Delete the last character + fi +}