From 49f9f334a52838d0c730acd7955f79c34acf958c Mon Sep 17 00:00:00 2001 From: magikcypress Date: Sun, 12 Mar 2017 00:57:49 +0100 Subject: [PATCH] Ajouter check_path dans .fonctions --- scripts/.fonctions | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/.fonctions b/scripts/.fonctions index e011d9c..30c75b8 100644 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -24,6 +24,15 @@ CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà u test ! -e "$final_path" || ynh_die "This path already contains a folder" } +CHECK_PATH () { # Checks / at the beginning of the path. And his absence at the end. + if [ "${path:0:1}" != "/" ]; then # If the first character is not / + path="/$path" # Add / at the beginning of path + fi + if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # If the last character is a / and it is not the only character. + path="${path:0:${#path}-1}" # Delete last character + fi +} + #================================================= # DISPLAYING #=================================================