From 4ec5050cbb9c42ad4979cf3ad830c7cf8826518c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 10 Feb 2016 17:28:48 +0100 Subject: [PATCH] backup: Hide status output for narrow terminals closes #428 --- cmd/restic/cmd_backup.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index 63a652cbf..4524001c2 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -153,9 +153,13 @@ func (cmd CmdBackup) newArchiveProgress(todo restic.Stat) *restic.Progress { w, _, err := terminal.GetSize(int(os.Stdout.Fd())) if err == nil { - if len(status1)+len(status2) > w { - max := w - len(status2) - 4 - status1 = status1[:max] + "... " + maxlen := w - len(status2) + + if maxlen < 4 { + status1 = "" + } else if len(status1) > maxlen { + status1 = status1[:maxlen-4] + status1 += "... " } }