From 1d0f472205c592bb4e5c0c00449fc8f493c25597 Mon Sep 17 00:00:00 2001 From: Giuseppe Maxia Date: Mon, 15 Jun 2020 20:41:28 +0200 Subject: [PATCH] Fix error handling on default dir detection Fix error handling on default dir detection for bash completion. --- .build/VERSION | 2 +- CHANGELOG.md | 6 ++++++ cmd/defaults.go | 19 ++++++++++--------- common/version.go | 4 ++-- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.build/VERSION b/.build/VERSION index c73f500e..aa618f0d 100644 --- a/.build/VERSION +++ b/.build/VERSION @@ -1 +1 @@ -1.51.1 +1.51.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b43de51..6312475f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.51.2 15-Jun-2020 + +### BUGS FIXED + +* Fix error handling on default directories detection for bash completion. + ## 1.51.1 14-Jun-2020 ### BUGS FIXED diff --git a/cmd/defaults.go b/cmd/defaults.go index aabb6ea3..0c27801e 100644 --- a/cmd/defaults.go +++ b/cmd/defaults.go @@ -114,18 +114,19 @@ func enableBashCompletion(cmd *cobra.Command, args []string) { destinationDir := path.Join("/etc", "bash_completion.d") alternateDestinationDir := path.Join("/usr", "local", "etc", "bash_completion.d") if !common.DirExists(destinationDir) { - destinationDir = alternateDestinationDir - } - if !common.DirExists(destinationDir) { - common.Exitf(1, "neither %s or %s found", destinationDir, alternateDestinationDir) - } - if !common.FileExists(bashCompletionScript) { - bashCompletionScript = alternateBashCompletionScript + if common.DirExists(alternateDestinationDir) { + destinationDir = alternateDestinationDir + } else { + common.Exitf(1, "neither %s or %s found", destinationDir, alternateDestinationDir) + } } if !common.FileExists(bashCompletionScript) { - common.Exitf(1, "neither %s or %s found", bashCompletionScript, alternateBashCompletionScript) + if common.FileExists(bashCompletionScript) { + bashCompletionScript = alternateBashCompletionScript + } else { + common.Exitf(1, "neither %s or %s found", bashCompletionScript, alternateBashCompletionScript) + } } - if completionFile == "" { completionFile = globals.CompletionFileValue } diff --git a/common/version.go b/common/version.go index 25a51b5d..dee26eea 100644 --- a/common/version.go +++ b/common/version.go @@ -16,9 +16,9 @@ package common // This file was generated during build. Do not edit. -// Build time: 2020-06-14 08:47 +// Build time: 2020-06-15 13:30 -var VersionDef string = "1.51.1" // 2020-06-14 +var VersionDef string = "1.51.2" // 2020-06-15 // Compatible version is the version used to mark compatible archives (templates, configuration). // It is usually major.minor.0, except when we are at version 0.x, when