From 03effd3bc9967da27db865ccb6480a805701b09f Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Mon, 7 Jul 2008 14:32:33 +0200 Subject: [PATCH] rules_generator: net rules - do not print error if file is missing and ignore commented rules Fix an error message displayed by write_net_rules when the rules file does not exist yet. (See Debian bugs #442796 and #475699.) Ignore commented rules, at least for the easy case. For clarity, use extended instead of standard regular expressions. --- extras/rule_generator/rule_generator.functions | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extras/rule_generator/rule_generator.functions b/extras/rule_generator/rule_generator.functions index 495bb7b0..aaf66a6f 100644 --- a/extras/rule_generator/rule_generator.functions +++ b/extras/rule_generator/rule_generator.functions @@ -92,6 +92,10 @@ find_all_rules() { local linkre="$2" local match="$3" - local search='.*[[:space:],]'"$key"'"\('"$linkre"'\)"[[:space:]]*\(,.*\|\\\|\)$' - echo $(sed -n -e "${match}s/${search}/\1/p" $RO_RULES_FILE $RULES_FILE 2>/dev/null) + local search='[[:space:],]'"$key"'"('"$linkre"')"[[:space:]]*(,.*|\\|)$' + + echo $(sed -n -r -e 's/^#.*//' -e "${match}s/${search}/\1/p" \ + $RO_RULES_FILE \ + $([ -e $RULES_FILE ] && echo $RULES_FILE) \ + 2>/dev/null) } -- 2.39.5