From 301b4e18ff8fc87f2a10d0c471c93df55fe0abc4 Mon Sep 17 00:00:00 2001
From: Steven Armstrong <steven@icarus.ethz.ch>
Date: Tue, 11 Mar 2014 21:07:20 +0100
Subject: [PATCH] either to it all, or fail; echo and cat suck, printf ftw!

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
---
 cdist/conf/type/__link/gencode-remote | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/cdist/conf/type/__link/gencode-remote b/cdist/conf/type/__link/gencode-remote
index 7582863f..9e7831c7 100755
--- a/cdist/conf/type/__link/gencode-remote
+++ b/cdist/conf/type/__link/gencode-remote
@@ -47,24 +47,22 @@ case "$state_should" in
     present)
         if [ "$file_type" = "directory" ]; then
             # our destination is currently a directory, delete it
-            cat << DONE
-rm -rf "$destination"
-DONE
-        fi
-
-        if [ "$state_is" = "wrongsource" ]; then
-            printf 'rm -f "%s"\n' "$destination"
+            printf 'rm -rf "%s" &&\n' "$destination"
+        else
+           if [ "$state_is" = "wrongsource" ]; then
+               # our destination is a symlink but points to the wrong source,
+               # delete it
+               printf 'rm -f "%s" &&\n' "$destination"
+           fi
         fi
 
         # create our link
-        cat << DONE
-ln ${lnopt} -f "$source" "$destination"
-DONE
+        printf 'ln %s -f "%s" "%s"\n' "$lnopt" "$source" "$destination"
     ;;
     absent)
         # only delete if it is a sym/hard link
         if [ "$file_type" = "symlink" -o "$file_type" = "hardlink" ]; then
-            echo rm -f \"$destination\"
+            printf 'rm -f "%s"\n' "$destination"
         fi
     ;;
     *)