From 5e2d77f65feb2d33ccc05d74ead69aa97ffd1498 Mon Sep 17 00:00:00 2001 From: Gabriel Gonzalez Date: Sun, 18 Jan 2015 20:52:06 -0800 Subject: [PATCH] Updated `touch` to also create the file if missing --- src/Turtle/Prelude.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Turtle/Prelude.hs b/src/Turtle/Prelude.hs index d5e403f..5891dc1 100644 --- a/src/Turtle/Prelude.hs +++ b/src/Turtle/Prelude.hs @@ -276,7 +276,11 @@ testdir = Filesystem.isDirectory Creates the file if it does not exist -} touch :: FilePath -> IO () -touch file = touchFile (Filesystem.encodeString file) +touch file = do + exists <- testfile file + if exists + then touchFile (Filesystem.encodeString file) + else sh (fileOut file empty) #endif {-| Create a temporary directory underneath the given directory