From b9fa9d8b113e1b8906bc8f9dbdf399d57af5e743 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@kr.ethz.ch>
Date: Wed, 2 Feb 2011 21:43:11 +0100
Subject: [PATCH] switch from chars to sane_regexp

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
---
 bin/cdist-config       | 2 +-
 bin/cdist_tree_wrapper | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/cdist-config b/bin/cdist-config
index b0966487..aaba9c74 100755
--- a/bin/cdist-config
+++ b/bin/cdist-config
@@ -58,7 +58,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname"
 __cdist_bin_prefix="__"
 
 # Used for IDs
-__cdist_sane_chars='[A-Za-z0-9_]'
+__cdist_sane_regexp='[A-Za-z0-9]*[-A-Za-z0-9_]*'
 
 # Used to mark file that created a specific type
 __cdist_object_source=".source"
diff --git a/bin/cdist_tree_wrapper b/bin/cdist_tree_wrapper
index b5d073fc..d7a2af6c 100755
--- a/bin/cdist_tree_wrapper
+++ b/bin/cdist_tree_wrapper
@@ -32,7 +32,7 @@ echo "I am $__cdist_myname and have been called with $@"
 
 __cdist_id="$1"; shift
 
-echo "$__cdist_id" | grep -q "^${__cdist_sane_chars}*\$" || __cdist_usage "Provide sane id, please"
+echo "$__cdist_id" | grep -q "^${__cdist_sane_regexp}\$" || __cdist_usage "Provide sane id, please"
 
 __cdist_tid="${__cdist_myname}/${__cdist_id}"
 __cdist_ddir="$(__cdist_cache_host)/${__cdist_tid}"
@@ -47,7 +47,7 @@ mkdir -p "${__cdist_ddir}"
 while [ $# -gt 0 ]; do
    opt="$1"; shift
 
-   echo "$opt" | grep -q "^--${__cdist_sane_chars}*\$" || __cdist_usage "Provide sane options"
+   echo "$opt" | grep -q "^--${__cdist_sane_regexp}\$" || __cdist_usage "Provide sane options"
 
    opt_file="$(echo $opt | sed 's/^--//')"