From 19e6ea9c801704d40dfe33df6c978d33b4e19c53 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 23 Mar 2011 10:47:13 +0100 Subject: [PATCH] begin restructure, use name __cdist_object_self for type/object_id combination Signed-off-by: Nico Schottelius --- bin/cdist-type-emulator | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/bin/cdist-type-emulator b/bin/cdist-type-emulator index 0b9a10ed..17b6cae6 100755 --- a/bin/cdist-type-emulator +++ b/bin/cdist-type-emulator @@ -27,26 +27,39 @@ . cdist-config set -eu +################################################################################ +# Prepare object and type +# + __cdist_type="$__cdist_myname" # Find out whether type is a singleton or regular type if [ -f "$(__cdist_type_singleton "$__cdist_type")" ]; then - __cdist_object_id="singleton" + __cdist_object_id="$__cdist_name_singleton" else [ $# -ge 1 ] || __cdist_usage " " __cdist_object_id="$1"; shift fi -echo "$__cdist_object_id" | grep -q "^${__cdist_sane_regexp}\$" || \ +# Verify object id +__cdist_object_id_sane=$(echo "$__cdist_object_id" | grep "^${__cdist_sane_regexp}\$") +if [ -z "$__cdist_object_id_sane" ]; then __cdist_usage "Insane object id, ${__cdist_object_id}." +fi -# Remove double slash if id begins with / +# Prevent double slash if id begins with / if [ "$(echo $__cdist_object_id | grep "^/")" ]; then - __cdist_object="${__cdist_type}${__cdist_object_id}" + __cdist_object_self="${__cdist_type}${__cdist_object_id}" else - __cdist_object="${__cdist_type}/${__cdist_object_id}" + __cdist_object_self="${__cdist_type}/${__cdist_object_id}" fi +################################################################################ +# Verify object +# + + + __cdist_ddir="$(__cdist_object_dir "$__cdist_object")" __cdist_parameter_dir="$(__cdist_object_parameter_dir "$__cdist_object")"