Merge pull request #1589 from YunoHost/fix-write-var-redundant-keys

[fix] Write var in files with redundants keys
This commit is contained in:
Alexandre Aubin 2023-02-06 14:00:38 +01:00 committed by GitHub
commit b7c5913683
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -568,7 +568,7 @@ ynh_read_var_in_file() {
var_part+='\s*' var_part+='\s*'
# Extract the part after assignation sign # Extract the part after assignation sign
local expression_with_comment="$(tail +$line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL | head -n1)" local expression_with_comment="$((tail +$line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
set -o xtrace # set -x set -o xtrace # set -x
echo YNH_NULL echo YNH_NULL
@ -647,7 +647,7 @@ ynh_write_var_in_file() {
var_part+='\s*' var_part+='\s*'
# Extract the part after assignation sign # Extract the part after assignation sign
local expression_with_comment="$(tail +$line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL | head -n1)" local expression_with_comment="$((tail +$line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
set -o xtrace # set -x set -o xtrace # set -x
return 1 return 1