From 613d66b7a702950fdec68ec5fd5bdc328092aac3 Mon Sep 17 00:00:00 2001
From: Daniel Heule <hda@sfs.biz>
Date: Thu, 9 Jan 2014 16:09:49 +0100
Subject: [PATCH] corrected man page and gencode update for correct messages

---
 cdist/conf/type/__directory/gencode-remote | 16 +++++++++-------
 cdist/conf/type/__directory/man.text       | 15 +++++++++++++++
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/cdist/conf/type/__directory/gencode-remote b/cdist/conf/type/__directory/gencode-remote
index 05c301b3..aba618ac 100755
--- a/cdist/conf/type/__directory/gencode-remote
+++ b/cdist/conf/type/__directory/gencode-remote
@@ -2,6 +2,7 @@
 #
 # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
 # 2013 Steven Armstrong (steven-cdist armstrong.cc)
+# 2014 Daniel Heule (hda at sfs.biz)
 #
 # This file is part of cdist.
 #
@@ -73,14 +74,15 @@ set_mode() {
 case "$state_should" in
    present)
       if [ "$type" != "directory" ]; then
-         # our destination is not a directory, remove whatever is there
-         # and then create our directory and set all attributes
          set_attributes=1
-         cat << DONE
-rm -f "$destination"
-mkdir $mkdiropt "$destination"
-DONE
-        echo "remove non directory" >> "$__messages_out"
+         if [ "$type" != "none" ]; then
+            # our destination is not a directory, remove whatever is there
+            # and then create our directory and set all attributes
+            echo rm -f "\"$destination\""
+            echo "remove non directory" >> "$__messages_out"
+         fi
+         echo "mkdir $mkdiropt \"$destination\""
+         echo "create" >> "$__messages_out"
       fi
 
       # Note: Mode - needs to happen last as a chown/chgrp can alter mode by
diff --git a/cdist/conf/type/__directory/man.text b/cdist/conf/type/__directory/man.text
index cc327af2..a0bf8062 100644
--- a/cdist/conf/type/__directory/man.text
+++ b/cdist/conf/type/__directory/man.text
@@ -46,6 +46,21 @@ recursive::
    If supplied the chgrp and chown call will run recursively.
    This does *not* influence the behaviour of chmod.
 
+MESSAGES
+--------
+chgrp <group>::
+    Changed group membership
+chown <owner>::
+    Changed owner
+chmod <mode>::
+    Changed mode
+create::
+    Empty directory was created
+remove::
+    Directory exists, but state is absent, directory will be removed by generated code.
+remove non directory::
+    Someting other than a directory with the same name exists and was removed prior to create.
+
 
 EXAMPLES
 --------