diff --git a/internal/run.go b/internal/run.go index 074ddee..73b8dbd 100644 --- a/internal/run.go +++ b/internal/run.go @@ -2,7 +2,6 @@ package internal import ( "fmt" - "strings" marecmd "github.com/femnad/mare/cmd" ) @@ -13,8 +12,7 @@ func maybeWarnPasswordRequired(cmdStr string) { return } - cmdHead := strings.Split(cmdStr, " ")[0] - Log.Warningf("Sudo authentication required for escalating privileges to run command %s", cmdHead) + Log.Warningf("Sudo authentication required for escalating privileges to run command `%s`", cmdStr) } func needsSudoForPath(dst string) (bool, error) { diff --git a/main.go b/main.go index 0c275f9..1a0e088 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ import ( ) const ( - version = "0.32.0" + version = "0.33.0" ) type args struct { diff --git a/provision/ensurelines.go b/provision/ensurelines.go index 8669863..5e05f68 100644 --- a/provision/ensurelines.go +++ b/provision/ensurelines.go @@ -84,12 +84,12 @@ func replace(file string, tmpFile *os.File, line entity.LineInFile) (result ensu var changed bool for scanner.Scan() { - var lineToWrite string - l := scanner.Text() - var absent bool + var found bool var oldLine string var newLine string + l := scanner.Text() + for _, needle := range replacements { var regex *regexp.Regexp absent = needle.Absent @@ -103,29 +103,27 @@ func replace(file string, tmpFile *os.File, line entity.LineInFile) (result ensu } if regex.MatchString(l) { - changed = true - if absent { - break - } - lineToWrite = newLine + found = true + l = newLine + break } } else if l == oldLine { - changed = true - lineToWrite = newLine - } else { - lineToWrite = l + found = true + l = newLine + break } } - if changed { + if found { delete(replacements, oldLine) + changed = true } if absent && changed { continue } - _, err = tmpFile.WriteString(lineToWrite + "\n") + _, err = tmpFile.WriteString(l + "\n") if err != nil { return }