Open polluks opened 6 months ago
We run check on CI so it works for us. Looks like an issue of NO_COLOR support, but I have no clue. Please describe more information about how you build and run tests.
That test is assuming that the login shell of the current user is a POSIX shell; it probably has something to do with that
Can you please try this patch?
diff --git a/tests/shtest b/tests/shtest
index 14aafbf..ca7e41f 100755
--- a/tests/shtest
+++ b/tests/shtest
@@ -507,11 +507,11 @@ test_no_color=true
$msys && test_no_color=false
$mingw && test_no_color=false
if $test_no_color && command -v script >/dev/null 2>&1; then
- unset NO_COLOR
- if script -qc echo /dev/null >/dev/null 2>&1; then
- faketty() { script -qec "$*" /dev/null; }
- else # macOS
- faketty() { script -q /dev/null "$@" /dev/null |
+ unset -v NO_COLOR
+ if script -qc true /dev/null >/dev/null 2>&1; then
+ faketty() { SHELL=sh script -qec "$*" /dev/null; }
+ else # BSD
+ faketty() { SHELL=sh script -q /dev/null -- "$@" /dev/null |
sed 's/^\x5E\x44\x08\x08//'; }
fi
Also, I am confused by that sed
command on MacOS, because I am pretty sure s/^/\x12/
does not work in macOS sed.
Maybe s/^\x12//
works though. Could someone check with printf '\x12HELLO\n' | sed -n 's/^\x12//; l'
on macOS?
(If you see just HELLO$
, it works; if you see somethingHELLO$
it does not work)
In any case, we should probably just use something more portable like bs=$(printf \\b); sed "1s/^^D$bs$bs//"
@emanuele6 macOS
$ printf '\x12HELLO\n' | sed -n 's/^\x12//; l'
HELLO$
@emanuele6 Sorry, your patch didn't help. I'm using a simple bash.
_____ stefan@Stefan-PC
/ __ \ os Debian GNU/Linux 10 (buster) on Windows 10 [WSL2]
| / | host x86_64
| \___- kernel 4.4.0-19041-Microsoft
-_ uptime 30m
--_ pkgs 1434
memory 6192M / 16335M
@polluks Can you try the following commands on the terminal?
/home/stefan/g/jq/jq --version
NO_COLOR=1 /home/stefan/g/jq/jq -n . | od -tc
NO_COLOR=1 script -qec /home/stefan/g/jq/jq -n . /dev/null | od -tc
Or
/home/stefan/g/jq/jq --version
NO_COLOR=1 /home/stefan/g/jq/jq -n . | od -tc
NO_COLOR=1 script -qec '/home/stefan/g/jq/jq -n .' /dev/null | od -tc
$ /home/stefan/g/jq/jq --version
jq-1.6rc1-510-gfb8cc53-dirty
$ NO_COLOR=1 /home/stefan/g/jq/jq -n . | od -tc
0000000 n u l l \n
0000005
$ NO_COLOR=1 script -qec '/home/stefan/g/jq/jq -n .' /dev/null | od -tc
0000000 n u l l \r \n
0000006
$ NO_COLOR=1 script -qec /home/stefan/g/jq/jq -n . /dev/null | od -tc
script: invalid option -- 'n'
Try 'script --help' for more information.
0000000
$ script --version
script from util-linux 2.33.1
$SHELL --version
export X=1; f() { printenv X; }; X=2 f
$ $SHELL --version
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ export X=1; f() { printenv X; }; X=2 f
2
Can you try with /bin/sh -c
?
/bin/sh -xc 'NO_COLOR=1 script -qec "/home/stefan/g/jq/jq -n ." /dev/null | od -tc'
$ /bin/sh -xc 'NO_COLOR=1 script -qec "/home/stefan/g/jq/jq -n ." /dev/null | od -tc'
+ NO_COLOR=1 script -qec /home/stefan/g/jq/jq -n . /dev/null
+ od -tc
0000000 n u l l \r \n
0000006
@polluks Did you find any other clue? You're the only one that can debug step by step so appreciated if you can find the cause yourself. Otherwise I'm thinking of closing this issue because there was no further context provided and the test implementation looks correct.
Describe the bug FAIL: tests/shtest
To Reproduce make check
Expected behavior FAIL: 0
Environment:
Additional context test-suite.log