Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tput error inside Docker #134

Open
mjsteinbaugh opened this issue Jun 21, 2020 · 5 comments
Open

tput error inside Docker #134

mjsteinbaugh opened this issue Jun 21, 2020 · 5 comments
Labels

Comments

@mjsteinbaugh
Copy link

Hi, I'm seeing this error pop up inside Docker images using shunit2 for unit tests:

tput: No value for $TERM and no -T specified
/usr/local/bin/shunit2: line 840: [: : integer expression expected

It seems like this issue has popped up for CI tests previously, as reported in #86 and #88.
This post also seems to be relevant.

I'm trying to set ARG TERM=xterm-256color inside my Dockerfile to see if this fixes the issue and will report back.

Any advice or ideas on how to handle this issue? Thanks!

@kward
Copy link
Owner

kward commented Oct 23, 2021

Can you try with the latest version from HEAD, and report back whether this error still appears?

@kward kward added the bug label Oct 23, 2021
@mjsteinbaugh
Copy link
Author

@kward Sure I'll try to test this out and get back to you

@williamdes
Copy link
Collaborator

Hi @kward !
I have this error on my Debian package: https://salsa.debian.org/debian/shunit2/-/jobs/3587857#L672

It's because tput is missing. It prevents the new version to enter debian as it breaks most of the projects using shunit2.
See: https://tracker.debian.org/pkg/shunit2

I am going to craft a patch for this, can you also have a look ?

@williamdes
Copy link
Collaborator

Edit: tput exists but it says tput: unknown terminal "unknown"

@williamdes
Copy link
Collaborator

williamdes commented Nov 28, 2022

See: https://opensource.apple.com/source/ncurses/ncurses-7/ncurses/progs/tput.c.auto.html

I did some debug

echo "colors 1: $(${SHUNIT_CMD_TPUT} colors)"
echo "colors 2: $(${SHUNIT_CMD_TPUT} colors 2>/dev/null)"
  if command [ $? -eq 0 ]; then
    echo "c: $?"
  else
    echo "cc: 16"
  fi

${SHUNIT_CMD_TPUT} colors 2>/dev/null
echo "c: $?"

${SHUNIT_CMD_TPUT} colors
echo "c: $?"
tput: No value for $TERM and no -T specified
colors 1: 
colors 2: 
c: 0
c: 2
tput: No value for $TERM and no -T specified
c: 2

The fix:

From: William Desportes <[email protected]>
Date: Mon, 28 Nov 2022 15:42:19 +0100
Subject: Fix error with tput when $TERM is not set

Origin: vendor
Forwarded: https://github.com/kward/shunit2/issues/134
---
 shunit2 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/shunit2 b/shunit2
index 6239683..b9b4603 100755
--- a/shunit2
+++ b/shunit2
@@ -1027,6 +1027,12 @@ _shunit_configureColor() {
 
 # colors returns the number of supported colors for the TERM.
 _shunit_colors() {
+  # Avoid: tput: No value for $TERM and no -T specified
+  if command [ -z "${TERM:-}" ]; then
+    echo 16
+    return
+  fi
+
   _shunit_tput_=`${SHUNIT_CMD_TPUT} colors 2>/dev/null`
   if command [ $? -eq 0 ]; then
     echo "${_shunit_tput_}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants