diff --git a/helpers/utils b/helpers/utils index 60cbedb5c..01a8a1371 100644 --- a/helpers/utils +++ b/helpers/utils @@ -513,7 +513,7 @@ ynh_read_var_in_file() { # Get the line number after which we search for the variable local line_number=1 if [[ -n "$after" ]]; then - line_number=$(grep -n $after $file | cut -d: -f1) + line_number=$(grep -m1 -n $after $file | cut -d: -f1) if [[ -z "$line_number" ]]; then set -o xtrace # set -x return 1 @@ -591,7 +591,7 @@ ynh_write_var_in_file() { # Get the line number after which we search for the variable local line_number=1 if [[ -n "$after" ]]; then - line_number=$(grep -n $after $file | cut -d: -f1) + line_number=$(grep -m1 -n $after $file | cut -d: -f1) if [[ -z "$line_number" ]]; then set -o xtrace # set -x return 1