Nouveau helper ynh_check_path

Nouveau helper pour vérifier et corriger la syntaxe du path.
Et ça permet de passer le test "incorrect_path" de package check
This commit is contained in:
Maniack Crudelis 2017-01-22 21:27:04 +01:00 committed by GitHub
parent fc7c35c319
commit 13ab4fa822

15
data/helpers.d/network Normal file
View file

@ -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
}