From 8e76a02a567981662e45ffb95b721482a43c41a5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 2 Mar 2015 09:11:49 -0800 Subject: [PATCH] command: disable backup with "-" [GH-1072] /cc @phinze --- command/apply_test.go | 6 ++++++ command/state.go | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/command/apply_test.go b/command/apply_test.go index 23638fc72..57e8c01c6 100644 --- a/command/apply_test.go +++ b/command/apply_test.go @@ -1113,6 +1113,12 @@ func TestApply_disableBackup(t *testing.T) { if err == nil || !os.IsNotExist(err) { t.Fatalf("backup should not exist") } + + // Ensure there is no literal "-" + _, err = os.Stat("-") + if err == nil || !os.IsNotExist(err) { + t.Fatalf("backup should not exist") + } } func testHttpServer(t *testing.T) net.Listener { diff --git a/command/state.go b/command/state.go index 9fceb61e7..20cb4c1e4 100644 --- a/command/state.go +++ b/command/state.go @@ -154,9 +154,11 @@ func State(opts *StateOpts) (*StateResult, error) { backupPath = opts.BackupPath } - result.State = &state.BackupState{ - Real: result.State, - Path: backupPath, + if backupPath != "-" { + result.State = &state.BackupState{ + Real: result.State, + Path: backupPath, + } } }