--regex to make __addifnosuchline more flexible

This commit is contained in:
phrawzty (dan) 2012-01-05 11:08:16 +01:00
parent 745cf47e43
commit 6d55d7ae82
2 changed files with 9 additions and 2 deletions

View File

@ -26,12 +26,18 @@ else
file="/$__object_id"
fi
regex=$(cat "$__object/parameter/line")
if [ -f "$__object/parameter/regex" ]; then
regex=$(cat "$__object/parameter/regex")
else
wrap=$(cat "$__object/parameter/line")
regex="^$wrap\$"
fi
if [ -f "$file" ]; then
# sh -e is our environment, we know what we do,
# skip error detection for now
set +e
grep -q "^$regex\$" "$file"
grep -q "$regex" "$file"
if [ $? -eq 1 ]; then
echo "NOTFOUND"
else

View File

@ -1 +1,2 @@
file
regex