This commit is contained in:
Nuno Cruces 2021-05-22 11:29:23 +01:00
parent 6e3393bd4f
commit 598ce272cb

View file

@ -3,6 +3,7 @@
package zenity package zenity
import ( import (
"bytes"
"os/exec" "os/exec"
"strconv" "strconv"
"strings" "strings"
@ -55,8 +56,9 @@ func appendIcon(args []string, opts options) []string {
} }
func strResult(opts options, out []byte, err error) (string, error) { func strResult(opts options, out []byte, err error) (string, error) {
out = bytes.TrimSuffix(out, []byte{'\n'})
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 { if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 {
if opts.extraButton != nil && *opts.extraButton+"\n" == string(out) { if opts.extraButton != nil && *opts.extraButton == string(out) {
return "", ErrExtraButton return "", ErrExtraButton
} }
return "", ErrCanceled return "", ErrCanceled