summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorAlexander Neumann <alexander@bumpern.de>2016-02-10 17:28:48 +0100
committerAlexander Neumann <alexander@bumpern.de>2016-02-10 17:28:48 +0100
commit4ec5050cbb9c42ad4979cf3ad830c7cf8826518c (patch)
tree42875954c42e050e36899189d2ab0c02b67bda79 /cmd
parenteccbcb73a182b10cbeda2b98bc7e37d04d5cfe75 (diff)
backup: Hide status output for narrow terminals
closes #428
Diffstat (limited to 'cmd')
-rw-r--r--cmd/restic/cmd_backup.go10
1 files 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 += "... "
}
}