From 2f26fb8834564724c72ef3c5d1e9ea32547c2ab4 Mon Sep 17 00:00:00 2001
From: Alexander Neumann <alexander@bumpern.de>
Date: Wed, 13 Dec 2017 19:57:05 +0100
Subject: [PATCH] Only print cache warning for terminals

---
 cmd/restic/global.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/cmd/restic/global.go b/cmd/restic/global.go
index 6827f512d..d472d8a34 100644
--- a/cmd/restic/global.go
+++ b/cmd/restic/global.go
@@ -388,8 +388,10 @@ func OpenRepository(opts GlobalOptions) (*repository.Repository, error) {
 			}
 		}
 	} else {
-		Verbosef("found %d old cache directories in %v, pass --cleanup-cache to remove them\n",
-			len(oldCacheDirs), c.Base)
+		if stdoutIsTerminal() {
+			Verbosef("found %d old cache directories in %v, pass --cleanup-cache to remove them\n",
+				len(oldCacheDirs), c.Base)
+		}
 	}
 
 	return s, nil