mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
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:
parent
fc7c35c319
commit
13ab4fa822
1 changed files with 15 additions and 0 deletions
15
data/helpers.d/network
Normal file
15
data/helpers.d/network
Normal 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
|
||||
}
|
Loading…
Add table
Reference in a new issue