From 6d55d7ae82fde29c943cde649cc8b9c767ceea14 Mon Sep 17 00:00:00 2001
From: "phrawzty (dan)" <phrawzty+github@gmail.com>
Date: Thu, 5 Jan 2012 11:08:16 +0100
Subject: [PATCH] --regex to make __addifnosuchline more flexible

---
 conf/type/__addifnosuchline/explorer/findline  | 10 ++++++++--
 conf/type/__addifnosuchline/parameter/optional |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/conf/type/__addifnosuchline/explorer/findline b/conf/type/__addifnosuchline/explorer/findline
index ac69a827..b45bd6ea 100755
--- a/conf/type/__addifnosuchline/explorer/findline
+++ b/conf/type/__addifnosuchline/explorer/findline
@@ -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
diff --git a/conf/type/__addifnosuchline/parameter/optional b/conf/type/__addifnosuchline/parameter/optional
index f73f3093..7ecfcde9 100644
--- a/conf/type/__addifnosuchline/parameter/optional
+++ b/conf/type/__addifnosuchline/parameter/optional
@@ -1 +1,2 @@
 file
+regex