yunohost/data/apps/helpers.d/utils
2015-09-29 18:45:07 +02:00

24 lines
593 B
Text

# Extract a key from a plain command output
#
# usage: ynh_get_plain_key key [subkey [subsubkey ...]]
# | ret: string - the key's value
ynh_get_plain_key() {
prefix="#"
founded=0
key=$1
shift
while read line; do
if [[ "$founded" == "1" ]] ; then
[[ "$line" =~ ^${prefix}[^#] ]] && return
echo $line
elif [[ "$line" =~ ^${prefix}${key}$ ]]; then
if [[ -n "$1" ]]; then
prefix+="#"
key=$1
shift
else
founded=1
fi
fi
done
}