--- a/pre-commit-src/pre-commit-script.sh
+++ b/pre-commit-src/pre-commit-script.sh
@@ -145,19 +145,19 @@ get_staged_version_of_a_file() {
parse_template_data() {
local template="$1"
local -n file_data_nameref=$2
local staged_template
get_staged_version_of_a_file "$template" staged_template
# Extract lines starting with %domainsVariables exceptionrules: and process them with jq
- local json_files_in_template=$(grep "^%domainsVariables exceptionrules:" <<< $staged_template | sed 's/^%domainsVariables exceptionrules://; s/%$//' | jq -Rs 'split("\n") | map(select(length > 0))' || echo '[]')
+ local json_files_in_template=$(grep "^%domainsVariables exceptionrules:" <<< $staged_template | sed 's/^%domainsVariables exceptionrules://; s/%$//' | jq -Rs 'split("\n") | map(select(length > 0))' || echo '')
# Extract lines starting with %include exceptionrules: and process them with jq
- local included_filterlists_files_in_template=$(grep "^%include exceptionrules:" <<< $staged_template | sed 's/^%include exceptionrules://; s/%$//' | jq -Rs 'split("\n") | map(select(length > 0))' || echo '[]')
+ local included_filterlists_files_in_template=$(grep "^%include exceptionrules:" <<< $staged_template | sed 's/^%include exceptionrules://; s/%$//' | jq -Rs 'split("\n") | map(select(length > 0))' || echo '')
if [ "$included_filterlists_files_in_template" = "[]" ]; then
last_error="ERROR: There is no list included in template $template_name"
return 1
fi
# Create a JSON object with the template name as the key and the extracted domainsVariables and include data as values
file_data_nameref=$(jq -n --arg template "$template" --argjson json_files_in_template "$json_files_in_template" --argjson included_filterlists_files_in_template "$included_filterlists_files_in_template" '