Browse Source

Remove ppc from freebsd as it is not available in go1.18beta1. Check error in Getsize(). (#137)

Guillaume J. Charmes 6 months ago
parent
commit
edfd13da2a
2 changed files with 17 additions and 14 deletions
  1. 13 13
      test_crosscompile.sh
  2. 4 1
      winsize.go

+ 13 - 13
test_crosscompile.sh

@@ -4,30 +4,30 @@
 # Does not actually test the logic, just the compilation so we make sure we don't break code depending on the lib.
 
 echo2() {
-    echo $@ >&2
+  echo $@ >&2
 }
 
 trap end 0
 end() {
-    [ "$?" = 0 ] && echo2 "Pass." || (echo2 "Fail."; exit 1)
+  [ "$?" = 0 ] && echo2 "Pass." || (echo2 "Fail."; exit 1)
 }
 
 cross() {
-    os=$1
-    shift
-    echo2 "Build for $os."
-    for arch in $@; do
-      echo2 "  - $os/$arch"
-      GOOS=$os GOARCH=$arch go build
-    done
-    echo2
+  os=$1
+  shift
+  echo2 "Build for $os."
+  for arch in $@; do
+    echo2 "  - $os/$arch"
+    GOOS=$os GOARCH=$arch go build
+  done
+  echo2
 }
 
 set -e
 
 cross linux     amd64 386 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le
 cross darwin    amd64 arm64
-cross freebsd   amd64 386 arm arm64 ppc64
+cross freebsd   amd64 386 arm arm64
 cross netbsd    amd64 386 arm arm64
 cross openbsd   amd64 386 arm arm64
 cross dragonfly amd64
@@ -41,8 +41,8 @@ cross windows amd64 386 arm
 
 # Some os/arch require a different compiler. Run in docker.
 if ! hash docker; then
-    # If docker is not present, stop here.
-    return
+  # If docker is not present, stop here.
+  return
 fi
 
 echo2 "Build for linux."

+ 4 - 1
winsize.go

@@ -20,5 +20,8 @@ func InheritSize(pty, tty *os.File) error {
 // in each line) in terminal t.
 func Getsize(t *os.File) (rows, cols int, err error) {
 	ws, err := GetsizeFull(t)
-	return int(ws.Rows), int(ws.Cols), err
+	if err != nil {
+		return 0, 0, err
+	}
+	return int(ws.Rows), int(ws.Cols), nil
 }