From 657b05fd968837bed809bc1906b4602f979447bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 13 Mar 2023 11:31:36 +0800 Subject: [PATCH] Print command to shell error --- cmd/internal/build_shared/tag.go | 10 ++++------ common/settings/proxy_android.go | 6 +++--- common/settings/proxy_darwin.go | 16 ++++++++-------- common/settings/proxy_linux.go | 5 +++-- go.mod | 2 +- go.sum | 3 ++- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cmd/internal/build_shared/tag.go b/cmd/internal/build_shared/tag.go index 15dabb36..9a376385 100644 --- a/cmd/internal/build_shared/tag.go +++ b/cmd/internal/build_shared/tag.go @@ -1,18 +1,16 @@ package build_shared -import ( - "github.com/sagernet/sing/common" -) +import "github.com/sagernet/sing/common/shell" func ReadTag() (string, error) { - currentTag, err := common.Exec("git", "describe", "--tags").ReadOutput() + currentTag, err := shell.Exec("git", "describe", "--tags").ReadOutput() if err != nil { return currentTag, err } - currentTagRev, _ := common.Exec("git", "describe", "--tags", "--abbrev=0").ReadOutput() + currentTagRev, _ := shell.Exec("git", "describe", "--tags", "--abbrev=0").ReadOutput() if currentTagRev == currentTag { return currentTag[1:], nil } - shortCommit, _ := common.Exec("git", "rev-parse", "--short", "HEAD").ReadOutput() + shortCommit, _ := shell.Exec("git", "rev-parse", "--short", "HEAD").ReadOutput() return currentTagRev[1:] + "-" + shortCommit, nil } diff --git a/common/settings/proxy_android.go b/common/settings/proxy_android.go index 45306b34..c045cb09 100644 --- a/common/settings/proxy_android.go +++ b/common/settings/proxy_android.go @@ -6,8 +6,8 @@ import ( "github.com/sagernet/sing-box/adapter" C "github.com/sagernet/sing-box/constant" - "github.com/sagernet/sing/common" F "github.com/sagernet/sing/common/format" + "github.com/sagernet/sing/common/shell" ) var ( @@ -26,9 +26,9 @@ func init() { func runAndroidShell(name string, args ...string) error { if !useRish { - return common.Exec(name, args...).Attach().Run() + return shell.Exec(name, args...).Attach().Run() } else { - return common.Exec("sh", rishPath, "-c", F.ToString(name, " ", strings.Join(args, " "))).Attach().Run() + return shell.Exec("sh", rishPath, "-c", F.ToString(name, " ", strings.Join(args, " "))).Attach().Run() } } diff --git a/common/settings/proxy_darwin.go b/common/settings/proxy_darwin.go index 7cc66f43..595fb944 100644 --- a/common/settings/proxy_darwin.go +++ b/common/settings/proxy_darwin.go @@ -6,9 +6,9 @@ import ( "github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-tun" - "github.com/sagernet/sing/common" E "github.com/sagernet/sing/common/exceptions" F "github.com/sagernet/sing/common/format" + "github.com/sagernet/sing/common/shell" "github.com/sagernet/sing/common/x/list" ) @@ -34,13 +34,13 @@ func (p *systemProxy) update(event int) error { return err } if p.isMixed { - err = common.Exec("networksetup", "-setsocksfirewallproxy", interfaceDisplayName, "127.0.0.1", F.ToString(p.port)).Attach().Run() + err = shell.Exec("networksetup", "-setsocksfirewallproxy", interfaceDisplayName, "127.0.0.1", F.ToString(p.port)).Attach().Run() } if err == nil { - err = common.Exec("networksetup", "-setwebproxy", interfaceDisplayName, "127.0.0.1", F.ToString(p.port)).Attach().Run() + err = shell.Exec("networksetup", "-setwebproxy", interfaceDisplayName, "127.0.0.1", F.ToString(p.port)).Attach().Run() } if err == nil { - err = common.Exec("networksetup", "-setsecurewebproxy", interfaceDisplayName, "127.0.0.1", F.ToString(p.port)).Attach().Run() + err = shell.Exec("networksetup", "-setsecurewebproxy", interfaceDisplayName, "127.0.0.1", F.ToString(p.port)).Attach().Run() } return err } @@ -51,19 +51,19 @@ func (p *systemProxy) unset() error { return err } if p.isMixed { - err = common.Exec("networksetup", "-setsocksfirewallproxystate", interfaceDisplayName, "off").Attach().Run() + err = shell.Exec("networksetup", "-setsocksfirewallproxystate", interfaceDisplayName, "off").Attach().Run() } if err == nil { - err = common.Exec("networksetup", "-setwebproxystate", interfaceDisplayName, "off").Attach().Run() + err = shell.Exec("networksetup", "-setwebproxystate", interfaceDisplayName, "off").Attach().Run() } if err == nil { - err = common.Exec("networksetup", "-setsecurewebproxystate", interfaceDisplayName, "off").Attach().Run() + err = shell.Exec("networksetup", "-setsecurewebproxystate", interfaceDisplayName, "off").Attach().Run() } return err } func getInterfaceDisplayName(name string) (string, error) { - content, err := common.Exec("networksetup", "-listallhardwareports").Read() + content, err := shell.Exec("networksetup", "-listallhardwareports").ReadOutput() if err != nil { return "", err } diff --git a/common/settings/proxy_linux.go b/common/settings/proxy_linux.go index f91f5829..193b94e0 100644 --- a/common/settings/proxy_linux.go +++ b/common/settings/proxy_linux.go @@ -11,6 +11,7 @@ import ( "github.com/sagernet/sing/common" E "github.com/sagernet/sing/common/exceptions" F "github.com/sagernet/sing/common/format" + "github.com/sagernet/sing/common/shell" ) var ( @@ -27,9 +28,9 @@ func init() { func runAsUser(name string, args ...string) error { if os.Getuid() != 0 { - return common.Exec(name, args...).Attach().Run() + return shell.Exec(name, args...).Attach().Run() } else if sudoUser != "" { - return common.Exec("su", "-", sudoUser, "-c", F.ToString(name, " ", strings.Join(args, " "))).Attach().Run() + return shell.Exec("su", "-", sudoUser, "-c", F.ToString(name, " ", strings.Join(args, " "))).Attach().Run() } else { return E.New("set system proxy: unable to set as root") } diff --git a/go.mod b/go.mod index 9dd9b0ca..26a00763 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/sagernet/gomobile v0.0.0-20221130124640-349ebaa752ca github.com/sagernet/quic-go v0.0.0-20230202071646-a8c8afb18b32 github.com/sagernet/reality v0.0.0-20230312150606-35ea9af0e0b8 - github.com/sagernet/sing v0.1.8 + github.com/sagernet/sing v0.1.9-0.20230313033500-448948d26d1a github.com/sagernet/sing-dns v0.1.4 github.com/sagernet/sing-shadowsocks v0.1.2-0.20230221080503-769c01d6bba9 github.com/sagernet/sing-shadowtls v0.1.0 diff --git a/go.sum b/go.sum index 88581c18..fc480a2b 100644 --- a/go.sum +++ b/go.sum @@ -108,8 +108,9 @@ github.com/sagernet/quic-go v0.0.0-20230202071646-a8c8afb18b32/go.mod h1:QMCkxXA github.com/sagernet/reality v0.0.0-20230312150606-35ea9af0e0b8 h1:4M3+0/kqvJuTsimEORH0/vUYTpMDUETBH2zNUU38SUw= github.com/sagernet/reality v0.0.0-20230312150606-35ea9af0e0b8/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU= github.com/sagernet/sing v0.0.0-20220817130738-ce854cda8522/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY= -github.com/sagernet/sing v0.1.8 h1:6DKo2FkSHn0nUcjO7bAext/ai7y7pCusK/+fScBJ5Jk= github.com/sagernet/sing v0.1.8/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk= +github.com/sagernet/sing v0.1.9-0.20230313033500-448948d26d1a h1:JgPPxKLiqA95Z0oTp9FyYUfij8xsjS2rBWtpQ41zFTo= +github.com/sagernet/sing v0.1.9-0.20230313033500-448948d26d1a/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= github.com/sagernet/sing-dns v0.1.4 h1:7VxgeoSCiiazDSaXXQVcvrTBxFpOePPq/4XdgnUDN+0= github.com/sagernet/sing-dns v0.1.4/go.mod h1:1+6pCa48B1AI78lD+/i/dLgpw4MwfnsSpZo0Ds8wzzk= github.com/sagernet/sing-shadowsocks v0.1.2-0.20230221080503-769c01d6bba9 h1:qS39eA4C7x+zhEkySbASrtmb6ebdy5v0y2M6mgkmSO0=