From: Marco d'Itri Date: Mon, 7 Jul 2008 12:32:33 +0000 (+0200) Subject: rules_generator: net rules - do not print error if file is missing and ignore comment... X-Git-Tag: 174~1671 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03effd3bc9967da27db865ccb6480a805701b09f;p=systemd 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. --- 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) }