diff --git a/Gopkg.lock b/Gopkg.lock index d99323c..836d870 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,14 +2,12 @@ [[projects]] - digest = "1:01211d9a9303680551230d477e61f4e60cac079a115f4c227ec2143d0d7db9f7" name = "github.com/atotto/clipboard" packages = ["."] - pruneopts = "" - revision = "bb272b845f1112e10117e3e45ce39f690c0001ad" + revision = "aa9549103943c05f3e8951009cdb6a0bec2c8949" + version = "v0.1.1" [[projects]] - digest = "1:a3dfc9ce62b33a7bc9d03fb049552d95a2b740387d086858e56853f32e43af3e" name = "github.com/aws/aws-sdk-go" packages = [ "aws", @@ -36,39 +34,31 @@ "private/protocol/restxml", "private/protocol/xml/xmlutil", "service/s3", - "service/sts", + "service/sts" ] - pruneopts = "" revision = "d05c000e0b41647375a4093373eb1301e02c8a4e" version = "v1.10.22" [[projects]] - digest = "1:e988ed0ca0d81f4d28772760c02ee95084961311291bdfefc1b04617c178b722" name = "github.com/fatih/color" packages = ["."] - pruneopts = "" revision = "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4" version = "v1.7.0" [[projects]] - digest = "1:eb53021a8aa3f599d29c7102e65026242bdedce998a54837dc67f14b6a97c5fd" name = "github.com/fsnotify/fsnotify" packages = ["."] - pruneopts = "" revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" version = "v1.4.7" [[projects]] - digest = "1:eb26181e5ea224ef9d0294830a3ea3f409c6fa96b4b0d5c4ed65d933531ebcd7" name = "github.com/go-ini/ini" packages = ["."] - pruneopts = "" revision = "d3de07a94d22b4a0972deb4b96d790c2c0ce8333" version = "v1.28.0" [[projects]] branch = "master" - digest = "1:67a319430297a0aeae0fdeea317229ee2812e8c5a8bcce259e0fc3023e1c3997" name = "github.com/hashicorp/hcl" packages = [ ".", @@ -80,159 +70,121 @@ "hcl/token", "json/parser", "json/scanner", - "json/token", + "json/token" ] - pruneopts = "" revision = "f40e974e75af4e271d97ce0fc917af5898ae7bda" [[projects]] - digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] - pruneopts = "" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] - digest = "1:e6f0b9e4dced4b6b5fedb810e2125a9f74dfe2ef1598c55ecb25e8b3d8f514ea" name = "github.com/jmespath/go-jmespath" packages = ["."] - pruneopts = "" revision = "3433f3ea46d9f8019119e7dd41274e112a2359a9" version = "0.2.2" [[projects]] - digest = "1:dbf1cd03d963baddbc2b2a07305d62faa4ee39554bcb42324063bbe3826496af" name = "github.com/leonklingele/randomstring" packages = ["."] - pruneopts = "" revision = "fd6b15ed1c60f5417073a1171521a6b7bdc91964" version = "v1.0" [[projects]] - digest = "1:d244eb7b2d8e9f4c9355d215d65159c176603874ba10bfb7cbe6dcbd212813f5" name = "github.com/magiconair/properties" packages = ["."] - pruneopts = "" revision = "c3beff4c2358b44d0493c7dda585e7db7ff28ae6" version = "v1.7.6" [[projects]] - digest = "1:6a2993e0132764bf3af555645a7194621b0869afa3ec67152cd0f9af27fe6d8b" name = "github.com/marcsauter/single" packages = ["."] - pruneopts = "" - revision = "3f6ac6766709f17b529a516abd96745824431eb0" + revision = "f8bf46f26ec011cb275d59dbb51d1fae0a0a18a6" [[projects]] - digest = "1:9ea83adf8e96d6304f394d40436f2eb44c1dc3250d223b74088cc253a6cd0a1c" name = "github.com/mattn/go-colorable" packages = ["."] - pruneopts = "" revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" version = "v0.0.9" [[projects]] - digest = "1:3140e04675a6a91d2a20ea9d10bdadf6072085502e6def6768361260aee4b967" name = "github.com/mattn/go-isatty" packages = ["."] - pruneopts = "" revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c" version = "v0.0.4" [[projects]] - digest = "1:59d11e81d6fdd12a771321696bb22abdd9a94d26ac864787e98c9b419e428734" name = "github.com/mitchellh/go-homedir" packages = ["."] - pruneopts = "" revision = "b8bc1bf767474819792c23f32d8286a45736f1c6" [[projects]] branch = "master" - digest = "1:59fa50d593e5673a0dfffa1852b66fd700c05b35e368680b4b89a68fdb2c1379" name = "github.com/mitchellh/mapstructure" packages = ["."] - pruneopts = "" revision = "00c29f56e2386353d58c599509e8dc3801b0d716" [[projects]] - digest = "1:d60cfeee185019d4fcd35e8c89c83aff576e4723b6100300bf67b05be961388f" name = "github.com/pelletier/go-toml" packages = ["."] - pruneopts = "" revision = "acdc4509485b587f5e675510c4f2c63e90ff68a8" version = "v1.1.0" [[projects]] - digest = "1:876666e3416bc4357068fd10b4e5989346d561550e061f62998ca9bec6639750" name = "github.com/pkg/term" packages = [ ".", - "termios", + "termios" ] - pruneopts = "" - revision = "b1f72af2d63057363398bec5873d16a98b453312" + revision = "93e6c91493094ff99a036fea0040802a1e0a4f69" [[projects]] - digest = "1:dae0d7dd55563fd389e7263a32d2030022ef29cceff941336e53f6520e0308c0" name = "github.com/spf13/afero" packages = [ ".", - "mem", + "mem" ] - pruneopts = "" revision = "bb8f1927f2a9d3ab41c9340aa034f6b803f4359c" version = "v1.0.2" [[projects]] - digest = "1:d0b38ba6da419a6d4380700218eeec8623841d44a856bb57369c172fbf692ab4" name = "github.com/spf13/cast" packages = ["."] - pruneopts = "" revision = "8965335b8c7107321228e3e3702cab9832751bac" version = "v1.2.0" [[projects]] - digest = "1:7ab90c89d3f2dc627dcfc1676c852db1da9a8059091ab49975a07e281e7dd38c" name = "github.com/spf13/cobra" packages = ["."] - pruneopts = "" revision = "b26b538f693051ac6518e65672de3144ce3fbedc" [[projects]] branch = "master" - digest = "1:104517520aab91164020ab6524a5d6b7cafc641b2e42ac6236f6ac1deac4f66a" name = "github.com/spf13/jwalterweatherman" packages = ["."] - pruneopts = "" revision = "7c0cea34c8ece3fbeb2b27ab9b59511d360fb394" [[projects]] - digest = "1:261bc565833ef4f02121450d74eb88d5ae4bd74bfe5d0e862cddb8550ec35000" name = "github.com/spf13/pflag" packages = ["."] - pruneopts = "" revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" version = "v1.0.0" [[projects]] - digest = "1:3dab237cd3263a290d771d133fed777bb56c22e380b00ebe92e6531d5c8d3d0c" name = "github.com/spf13/viper" packages = ["."] - pruneopts = "" revision = "b5e8006cbee93ec955a89ab31e0e3ce3204f3736" version = "v1.0.2" [[projects]] - digest = "1:04349b046e02da62563d078f7464366c25188b9f01750cc5a0be9ad59c7fd974" name = "golang.leonklingele.de/securetemp" packages = ["."] - pruneopts = "" revision = "50a05cf002288328d2b1fdf97dd7ab9da3c004b1" version = "v1.0.0" [[projects]] - digest = "1:44c7f4a72f6b1d2961b30947d8222f0253645fa0fcb493f30d417325c1323227" name = "golang.org/x/crypto" packages = [ "cast5", @@ -247,24 +199,20 @@ "pbkdf2", "poly1305", "scrypt", - "ssh/terminal", + "ssh/terminal" ] - pruneopts = "" revision = "b176d7def5d71bdd214203491f89843ed217f420" [[projects]] branch = "master" - digest = "1:590053260f0642c48e3699048188a940ecfb4eb7ef3620ffaa836538e04029be" name = "golang.org/x/sys" packages = [ "unix", - "windows", + "windows" ] - pruneopts = "" revision = "e42485b6e20ae7d2304ec72e535b103ed350cc02" [[projects]] - digest = "1:5acd3512b047305d49e8763eef7ba423901e85d5dd2fd1e71778a0ea8de10bd4" name = "golang.org/x/text" packages = [ "internal/gen", @@ -272,45 +220,20 @@ "internal/ucd", "transform", "unicode/cldr", - "unicode/norm", + "unicode/norm" ] - pruneopts = "" revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" [[projects]] - digest = "1:fe5e951fa28e0afa18f3755b80ff1601817b65b00fb281e7a38256ccfeb9d8f3" name = "gopkg.in/yaml.v2" packages = ["."] - pruneopts = "" revision = "86f5ed62f8a0ee96bd888d2efdfd6d4fb100a4eb" version = "v2.2.0" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - input-imports = [ - "github.com/atotto/clipboard", - "github.com/aws/aws-sdk-go/aws", - "github.com/aws/aws-sdk-go/aws/awserr", - "github.com/aws/aws-sdk-go/aws/session", - "github.com/aws/aws-sdk-go/service/s3", - "github.com/fatih/color", - "github.com/leonklingele/randomstring", - "github.com/marcsauter/single", - "github.com/mitchellh/go-homedir", - "github.com/pkg/term", - "github.com/spf13/cobra", - "github.com/spf13/pflag", - "github.com/spf13/viper", - "golang.leonklingele.de/securetemp", - "golang.org/x/crypto/chacha20poly1305", - "golang.org/x/crypto/openpgp", - "golang.org/x/crypto/openpgp/armor", - "golang.org/x/crypto/openpgp/packet", - "golang.org/x/crypto/pbkdf2", - "golang.org/x/crypto/scrypt", - "golang.org/x/crypto/ssh/terminal", - ] + inputs-digest = "75de4a847ae5193b8b5cf2dcb2f897dd4a12527bd9540f0dd52b5d2ad84199b2" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 3010027..01963a3 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -23,12 +23,16 @@ [[constraint]] name = "github.com/atotto/clipboard" - revision = "bb272b845f1112e10117e3e45ce39f690c0001ad" + version = "v0.1.1" [[constraint]] name = "github.com/aws/aws-sdk-go" version = "v1.10.22" +[[constraint]] + name = "github.com/marcsauter/single" + revision = "f8bf46f26ec011cb275d59dbb51d1fae0a0a18a6" + [[constraint]] name = "github.com/leonklingele/randomstring" version = "1.0.0" @@ -39,7 +43,7 @@ [[constraint]] name = "github.com/pkg/term" - revision = "b1f72af2d63057363398bec5873d16a98b453312" + revision = "93e6c91493094ff99a036fea0040802a1e0a4f69" [[constraint]] name = "github.com/spf13/cobra" diff --git a/vendor/github.com/atotto/clipboard/.travis.yml b/vendor/github.com/atotto/clipboard/.travis.yml index f339196..5bd5ae3 100644 --- a/vendor/github.com/atotto/clipboard/.travis.yml +++ b/vendor/github.com/atotto/clipboard/.travis.yml @@ -1,11 +1,13 @@ language: go go: - - go1.2.2 - - go1.3.3 - go1.4.3 - - go1.5.3 - - go1.6 + - go1.5.4 + - go1.6.4 + - go1.7.6 + - go1.8.7 + - go1.9.4 + - go1.10 before_install: - export DISPLAY=:99.0 diff --git a/vendor/github.com/atotto/clipboard/README.md b/vendor/github.com/atotto/clipboard/README.md index 6e2d15f..41fdd57 100644 --- a/vendor/github.com/atotto/clipboard/README.md +++ b/vendor/github.com/atotto/clipboard/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/atotto/clipboard.svg?branch=master)](https://travis-ci.org/atotto/clipboard) [![Build Status](https://drone.io/github.com/atotto/clipboard/status.png)](https://drone.io/github.com/atotto/clipboard/latest) +[![Build Status](https://travis-ci.org/atotto/clipboard.svg?branch=master)](https://travis-ci.org/atotto/clipboard) [![GoDoc](https://godoc.org/github.com/atotto/clipboard?status.svg)](http://godoc.org/github.com/atotto/clipboard) @@ -6,8 +6,6 @@ Provide copying and pasting to the Clipboard for Go. -Download shell commands at https://drone.io/github.com/atotto/clipboard/files - Build: $ go get github.com/atotto/clipboard diff --git a/vendor/github.com/atotto/clipboard/clipboard.go b/vendor/github.com/atotto/clipboard/clipboard.go index 9e8f573..d7907d3 100644 --- a/vendor/github.com/atotto/clipboard/clipboard.go +++ b/vendor/github.com/atotto/clipboard/clipboard.go @@ -5,8 +5,6 @@ // Package clipboard read/write on clipboard package clipboard -import () - // ReadAll read string from clipboard func ReadAll() (string, error) { return readAll() diff --git a/vendor/github.com/atotto/clipboard/clipboard_unix.go b/vendor/github.com/atotto/clipboard/clipboard_unix.go index aa0ef3a..d4f0df2 100644 --- a/vendor/github.com/atotto/clipboard/clipboard_unix.go +++ b/vendor/github.com/atotto/clipboard/clipboard_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build freebsd linux netbsd openbsd solaris +// +build freebsd linux netbsd openbsd solaris dragonfly package clipboard @@ -12,11 +12,15 @@ import ( ) const ( - xsel = "xsel" - xclip = "xclip" + xsel = "xsel" + xclip = "xclip" + termuxClipboardGet = "termux-clipboard-get" + termuxClipboardSet = "termux-clipboard-set" ) var ( + Primary bool + pasteCmdArgs []string copyCmdArgs []string @@ -26,7 +30,10 @@ var ( xclipPasteArgs = []string{xclip, "-out", "-selection", "clipboard"} xclipCopyArgs = []string{xclip, "-in", "-selection", "clipboard"} - missingCommands = errors.New("No clipboard utilities available. Please install xsel or xclip.") + termuxPasteArgs = []string{termuxClipboardGet} + termuxCopyArgs = []string{termuxClipboardSet} + + missingCommands = errors.New("No clipboard utilities available. Please install xsel, xclip, or Termux:API add-on for termux-clipboard-get/set.") ) func init() { @@ -44,14 +51,29 @@ func init() { return } + pasteCmdArgs = termuxPasteArgs + copyCmdArgs = termuxCopyArgs + + if _, err := exec.LookPath(termuxClipboardSet); err == nil { + if _, err := exec.LookPath(termuxClipboardGet); err == nil { + return + } + } + Unsupported = true } func getPasteCommand() *exec.Cmd { + if Primary { + pasteCmdArgs = pasteCmdArgs[:1] + } return exec.Command(pasteCmdArgs[0], pasteCmdArgs[1:]...) } func getCopyCommand() *exec.Cmd { + if Primary { + copyCmdArgs = copyCmdArgs[:1] + } return exec.Command(copyCmdArgs[0], copyCmdArgs[1:]...) } diff --git a/vendor/github.com/atotto/clipboard/clipboard_windows.go b/vendor/github.com/atotto/clipboard/clipboard_windows.go index 5dbb562..4b4aedb 100644 --- a/vendor/github.com/atotto/clipboard/clipboard_windows.go +++ b/vendor/github.com/atotto/clipboard/clipboard_windows.go @@ -8,12 +8,13 @@ package clipboard import ( "syscall" + "time" "unsafe" ) const ( cfUnicodetext = 13 - gmemFixed = 0x0000 + gmemMoveable = 0x0002 ) var ( @@ -32,15 +33,31 @@ var ( lstrcpy = kernel32.NewProc("lstrcpyW") ) +// waitOpenClipboard opens the clipboard, waiting for up to a second to do so. +func waitOpenClipboard() error { + started := time.Now() + limit := started.Add(time.Second) + var r uintptr + var err error + for time.Now().Before(limit) { + r, _, err = openClipboard.Call(0) + if r != 0 { + return nil + } + time.Sleep(time.Millisecond) + } + return err +} + func readAll() (string, error) { - r, _, err := openClipboard.Call(0) - if r == 0 { + err := waitOpenClipboard() + if err != nil { return "", err } defer closeClipboard.Call() h, _, err := getClipboardData.Call(cfUnicodetext) - if r == 0 { + if h == 0 { return "", err } @@ -51,7 +68,7 @@ func readAll() (string, error) { text := syscall.UTF16ToString((*[1 << 20]uint16)(unsafe.Pointer(l))[:]) - r, _, err = globalUnlock.Call(h) + r, _, err := globalUnlock.Call(h) if r == 0 { return "", err } @@ -60,23 +77,30 @@ func readAll() (string, error) { } func writeAll(text string) error { - r, _, err := openClipboard.Call(0) - if r == 0 { + err := waitOpenClipboard() + if err != nil { return err } defer closeClipboard.Call() - r, _, err = emptyClipboard.Call(0) + r, _, err := emptyClipboard.Call(0) if r == 0 { return err } data := syscall.StringToUTF16(text) - h, _, err := globalAlloc.Call(gmemFixed, uintptr(len(data)*int(unsafe.Sizeof(data[0])))) + // "If the hMem parameter identifies a memory object, the object must have + // been allocated using the function with the GMEM_MOVEABLE flag." + h, _, err := globalAlloc.Call(gmemMoveable, uintptr(len(data)*int(unsafe.Sizeof(data[0])))) if h == 0 { return err } + defer func() { + if h != 0 { + globalFree.Call(h) + } + }() l, _, err := globalLock.Call(h) if l == 0 { @@ -90,12 +114,15 @@ func writeAll(text string) error { r, _, err = globalUnlock.Call(h) if r == 0 { - return err + if err.(syscall.Errno) != 0 { + return err + } } r, _, err = setClipboardData.Call(cfUnicodetext, h) if r == 0 { return err } + h = 0 // suppress deferred cleanup return nil } diff --git a/vendor/github.com/atotto/clipboard/go.mod b/vendor/github.com/atotto/clipboard/go.mod new file mode 100644 index 0000000..68ec980 --- /dev/null +++ b/vendor/github.com/atotto/clipboard/go.mod @@ -0,0 +1 @@ +module github.com/atotto/clipboard diff --git a/vendor/github.com/marcsauter/single/LICENSE b/vendor/github.com/marcsauter/single/LICENSE new file mode 100644 index 0000000..97b81c5 --- /dev/null +++ b/vendor/github.com/marcsauter/single/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Marc Sauter + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/marcsauter/single/README.md b/vendor/github.com/marcsauter/single/README.md index c7e2edb..33281fa 100644 --- a/vendor/github.com/marcsauter/single/README.md +++ b/vendor/github.com/marcsauter/single/README.md @@ -12,9 +12,15 @@ ) func main() { - s := single.New("name") - s.Lock() - defer s.Unlock() + s := single.New("your-app-name") + if err := s.CheckLock(); err != nil && err == single.ErrAlreadyRunning { + log.Fatal("another instance of the app is already running, exiting") + } else if err != nil { + // Another error occurred, might be worth handling it as well + log.Fatalf("failed to acquire exclusive app lock: %v", err) + } + defer s.TryUnlock() + log.Println("working") time.Sleep(60 * time.Second) log.Println("finished") diff --git a/vendor/github.com/marcsauter/single/single_freebsd.go b/vendor/github.com/marcsauter/single/single_bsd.go similarity index 86% rename from vendor/github.com/marcsauter/single/single_freebsd.go rename to vendor/github.com/marcsauter/single/single_bsd.go index e4629f8..58c35c7 100644 --- a/vendor/github.com/marcsauter/single/single_freebsd.go +++ b/vendor/github.com/marcsauter/single/single_bsd.go @@ -1,3 +1,5 @@ +// +build freebsd openbsd netbsd dragonfly + package single import ( diff --git a/vendor/github.com/marcsauter/single/single_unix.go b/vendor/github.com/marcsauter/single/single_unix.go index 1f9990d..30545f1 100644 --- a/vendor/github.com/marcsauter/single/single_unix.go +++ b/vendor/github.com/marcsauter/single/single_unix.go @@ -1,4 +1,4 @@ -// +build linux solaris darwin freebsd +// +build linux solaris darwin freebsd openbsd netbsd dragonfly package single diff --git a/vendor/github.com/pkg/term/.travis.yml b/vendor/github.com/pkg/term/.travis.yml index bd155c2..429c2ca 100644 --- a/vendor/github.com/pkg/term/.travis.yml +++ b/vendor/github.com/pkg/term/.travis.yml @@ -1,9 +1,8 @@ language: go go_import_path: github.com/pkg/term go: - - 1.4.3 - - 1.5.4 - - 1.6.2 + - 1.10.x + - 1.11.x - tip script: diff --git a/vendor/github.com/pkg/term/term_bsdi.go b/vendor/github.com/pkg/term/term_bsdi.go new file mode 100644 index 0000000..c539049 --- /dev/null +++ b/vendor/github.com/pkg/term/term_bsdi.go @@ -0,0 +1,55 @@ +// +build netbsd openbsd + +package term + +import "syscall" + +type attr syscall.Termios + +func (a *attr) setSpeed(baud int) error { + var rate int32 + switch baud { + case 50: + rate = syscall.B50 + case 75: + rate = syscall.B75 + case 110: + rate = syscall.B110 + case 134: + rate = syscall.B134 + case 150: + rate = syscall.B150 + case 200: + rate = syscall.B200 + case 300: + rate = syscall.B300 + case 600: + rate = syscall.B600 + case 1200: + rate = syscall.B1200 + case 1800: + rate = syscall.B1800 + case 2400: + rate = syscall.B2400 + case 4800: + rate = syscall.B4800 + case 9600: + rate = syscall.B9600 + case 19200: + rate = syscall.B19200 + case 38400: + rate = syscall.B38400 + case 57600: + rate = syscall.B57600 + case 115200: + rate = syscall.B115200 + case 230400: + rate = syscall.B230400 + default: + return syscall.EINVAL + } + (*syscall.Termios)(a).Cflag = syscall.CS8 | syscall.CREAD | syscall.CLOCAL | uint32(rate) + (*syscall.Termios)(a).Ispeed = rate + (*syscall.Termios)(a).Ospeed = rate + return nil +} diff --git a/vendor/github.com/pkg/term/term_bsd.go b/vendor/github.com/pkg/term/term_bsdu.go similarity index 96% rename from vendor/github.com/pkg/term/term_bsd.go rename to vendor/github.com/pkg/term/term_bsdu.go index 4446b3b..15ca279 100644 --- a/vendor/github.com/pkg/term/term_bsd.go +++ b/vendor/github.com/pkg/term/term_bsdu.go @@ -1,4 +1,4 @@ -// +build freebsd openbsd netbsd +// +build dragonfly freebsd package term diff --git a/vendor/github.com/pkg/term/term_open_posix.go b/vendor/github.com/pkg/term/term_open_posix.go index 66bf8cc..5efea56 100644 --- a/vendor/github.com/pkg/term/term_open_posix.go +++ b/vendor/github.com/pkg/term/term_open_posix.go @@ -5,7 +5,6 @@ package term import ( "os" "syscall" - "time" "github.com/pkg/term/termios" ) @@ -19,7 +18,6 @@ func Open(name string, options ...func(*Term) error) (*Term, error) { t := Term{name: name, fd: fd} if err := termios.Tcgetattr(uintptr(t.fd), &t.orig); err != nil { - time.Sleep(time.Second * 100) return nil, err } if err := t.SetOption(options...); err != nil { @@ -33,4 +31,3 @@ func Open(name string, options ...func(*Term) error) (*Term, error) { func (t *Term) Restore() error { return termios.Tcsetattr(uintptr(t.fd), termios.TCIOFLUSH, &t.orig) } - diff --git a/vendor/github.com/pkg/term/termios/pty_bsd.go b/vendor/github.com/pkg/term/termios/pty_bsd.go index d1a3baf..75fe179 100644 --- a/vendor/github.com/pkg/term/termios/pty_bsd.go +++ b/vendor/github.com/pkg/term/termios/pty_bsd.go @@ -1,41 +1,37 @@ -// +build freebsd openbsd netbsd +// +build dragonfly netbsd openbsd package termios -import ( - "fmt" - "syscall" - "unsafe" -) +// #include +import "C" -func posix_openpt(oflag int) (fd uintptr, err error) { - // Copied from debian-golang-pty/pty_freebsd.go. - r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0) - fd = uintptr(r0) - if e1 != 0 { - err = e1 - } - return -} +import "syscall" func open_pty_master() (uintptr, error) { - return posix_openpt(syscall.O_NOCTTY|syscall.O_RDWR|syscall.O_CLOEXEC) + rc := C.posix_openpt(syscall.O_NOCTTY | syscall.O_RDWR) + if rc < 0 { + return 0, syscall.Errno(rc) + } + return uintptr(rc), nil } func Ptsname(fd uintptr) (string, error) { - var n uintptr - err := ioctl(fd, syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) - if err != nil { - return "", err - } - return fmt.Sprintf("/dev/pts/%d", n), nil + slavename := C.GoString(C.ptsname(C.int(fd))) + return slavename, nil } func grantpt(fd uintptr) error { - var n uintptr - return ioctl(fd, syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) + rc := C.grantpt(C.int(fd)) + if rc == 0 { + return nil + } + return syscall.Errno(rc) } func unlockpt(fd uintptr) error { - return nil + rc := C.unlockpt(C.int(fd)) + if rc == 0 { + return nil + } + return syscall.Errno(rc) } diff --git a/vendor/github.com/pkg/term/termios/pty_freebsd.go b/vendor/github.com/pkg/term/termios/pty_freebsd.go new file mode 100644 index 0000000..e4b933a --- /dev/null +++ b/vendor/github.com/pkg/term/termios/pty_freebsd.go @@ -0,0 +1,39 @@ +package termios + +import ( + "fmt" + "syscall" + "unsafe" +) + +func posix_openpt(oflag int) (fd uintptr, err error) { + // Copied from debian-golang-pty/pty_freebsd.go. + r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0) + fd = uintptr(r0) + if e1 != 0 { + err = e1 + } + return +} + +func open_pty_master() (uintptr, error) { + return posix_openpt(syscall.O_NOCTTY|syscall.O_RDWR|syscall.O_CLOEXEC) +} + +func Ptsname(fd uintptr) (string, error) { + var n uintptr + err := ioctl(fd, syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) + if err != nil { + return "", err + } + return fmt.Sprintf("/dev/pts/%d", n), nil +} + +func grantpt(fd uintptr) error { + var n uintptr + return ioctl(fd, syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) +} + +func unlockpt(fd uintptr) error { + return nil +} diff --git a/vendor/github.com/pkg/term/termios/termios_bsd.go b/vendor/github.com/pkg/term/termios/termios_bsd.go index 7015065..cf1db3e 100644 --- a/vendor/github.com/pkg/term/termios/termios_bsd.go +++ b/vendor/github.com/pkg/term/termios/termios_bsd.go @@ -1,4 +1,4 @@ -// +build darwin freebsd openbsd netbsd +// +build darwin freebsd openbsd netbsd dragonfly package termios diff --git a/vendor/github.com/pkg/term/termios/termios_bsd_test.go b/vendor/github.com/pkg/term/termios/termios_bsd_test.go index 946f862..06d594c 100644 --- a/vendor/github.com/pkg/term/termios/termios_bsd_test.go +++ b/vendor/github.com/pkg/term/termios/termios_bsd_test.go @@ -1,4 +1,4 @@ -// +build darwin freebsd openbsd netbsd +// +build darwin freebsd openbsd netbsd dragonfly package termios diff --git a/vendor/github.com/pkg/term/termios/termios_test.go b/vendor/github.com/pkg/term/termios/termios_test.go index 2c90146..5051952 100644 --- a/vendor/github.com/pkg/term/termios/termios_test.go +++ b/vendor/github.com/pkg/term/termios/termios_test.go @@ -110,7 +110,7 @@ func TestTiocinq(t *testing.T) { t.Fatal(err) } if inq != 0 { - t.Fatal("Expected 0 bytes, got %v", inq) + t.Fatalf("Expected 0 bytes, got %v", inq) } } @@ -123,7 +123,7 @@ func TestTiocoutq(t *testing.T) { t.Fatal(err) } if inq != 0 { - t.Fatal("Expected 0 bytes, got %v", inq) + t.Fatalf("Expected 0 bytes, got %v", inq) } }