mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
config helpers: Disable bash xtrace during ynh_read/write_var_from_file to avoid an horrendous amount of debug logs
This commit is contained in:
parent
63d3ccd827
commit
47db3e798e
1 changed files with 10 additions and 0 deletions
|
@ -519,6 +519,8 @@ ynh_read_var_in_file() {
|
||||||
|
|
||||||
[[ -f $file ]] || ynh_die --message="File $file does not exists"
|
[[ -f $file ]] || ynh_die --message="File $file does not exists"
|
||||||
|
|
||||||
|
set +o xtrace # set +x
|
||||||
|
|
||||||
# Get the line number after which we search for the variable
|
# Get the line number after which we search for the variable
|
||||||
local line_number=1
|
local line_number=1
|
||||||
if [[ -n "$after" ]];
|
if [[ -n "$after" ]];
|
||||||
|
@ -526,6 +528,7 @@ ynh_read_var_in_file() {
|
||||||
line_number=$(grep -n $after $file | cut -d: -f1)
|
line_number=$(grep -n $after $file | cut -d: -f1)
|
||||||
if [[ -z "$line_number" ]];
|
if [[ -z "$line_number" ]];
|
||||||
then
|
then
|
||||||
|
set -o xtrace # set -x
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -555,6 +558,7 @@ ynh_read_var_in_file() {
|
||||||
# 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
|
||||||
echo YNH_NULL
|
echo YNH_NULL
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -570,6 +574,7 @@ ynh_read_var_in_file() {
|
||||||
else
|
else
|
||||||
echo "$expression"
|
echo "$expression"
|
||||||
fi
|
fi
|
||||||
|
set -o xtrace # set -x
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set a value into heterogeneous file (yaml, json, php, python...)
|
# Set a value into heterogeneous file (yaml, json, php, python...)
|
||||||
|
@ -594,6 +599,8 @@ ynh_write_var_in_file() {
|
||||||
|
|
||||||
[[ -f $file ]] || ynh_die --message="File $file does not exists"
|
[[ -f $file ]] || ynh_die --message="File $file does not exists"
|
||||||
|
|
||||||
|
set +o xtrace # set +x
|
||||||
|
|
||||||
# Get the line number after which we search for the variable
|
# Get the line number after which we search for the variable
|
||||||
local line_number=1
|
local line_number=1
|
||||||
if [[ -n "$after" ]];
|
if [[ -n "$after" ]];
|
||||||
|
@ -601,6 +608,7 @@ ynh_write_var_in_file() {
|
||||||
line_number=$(grep -n $after $file | cut -d: -f1)
|
line_number=$(grep -n $after $file | cut -d: -f1)
|
||||||
if [[ -z "$line_number" ]];
|
if [[ -z "$line_number" ]];
|
||||||
then
|
then
|
||||||
|
set -o xtrace # set -x
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -631,6 +639,7 @@ ynh_write_var_in_file() {
|
||||||
# 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
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -661,6 +670,7 @@ ynh_write_var_in_file() {
|
||||||
fi
|
fi
|
||||||
sed -ri "${range}s$delimiter(^${var_part}).*\$$delimiter\1${value}${endline}${delimiter}i" ${file}
|
sed -ri "${range}s$delimiter(^${var_part}).*\$$delimiter\1${value}${endline}${delimiter}i" ${file}
|
||||||
fi
|
fi
|
||||||
|
set -o xtrace # set -x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue