[fix] I like regexp

This commit is contained in:
ljf 2021-08-20 17:26:26 +02:00
parent 98ca514f8f
commit 2ac4e1c5bf

View file

@ -42,9 +42,9 @@ ynh_value_get() {
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local var_part="[ \t]*(\$?\w*\[)?[ \t]*[\"']?${key}[\"']?[ \t]*\]?[ \t]*[:=]>?[ \t]*"
local var_part='^[ \t]*\$?(\w*\[)?[ \t]*["'"']?${key}['"'"]?[ \t]*\]?[ \t]*[:=]>?[ \t]*'
local crazy_value="$(grep -i -o -P "^${var_part}\K.*(?=[ \t,\n;]*\$)" ${file} | head -n1)"
local crazy_value="$(grep -i -o -P '^[ \t]*\$?(\w*\[)?[ \t]*["'"']?${key}['"'"]?[ \t]*\]?[ \t]*[:=]>?[ \t]*\K.*(?=[ \t,\n;]*$)' ${file} | head -n1)"
local first_char="${crazy_value:0:1}"
if [[ "$first_char" == '"' ]] ; then