]> err.no Git - systemd/commitdiff
rules_generator: net rules - do not print error if file is missing and ignore comment...
authorMarco d'Itri <md@Linux.IT>
Mon, 7 Jul 2008 12:32:33 +0000 (14:32 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Mon, 7 Jul 2008 12:32:33 +0000 (14:32 +0200)
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

index 495bb7b04743caad1fe402521ecfc16e2b33e1bf..aaf66a6fa05dc4b514277067bf4d1d1f24043439 100644 (file)
@@ -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)
 }