Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Tests/X04: use temporary pattern matching for OpenBSD missing leading 0m
- X-seq: zsh-workers 44012
- From: dana <dana@xxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- Subject: Re: [PATCH] Tests/X04: use temporary pattern matching for OpenBSD missing leading 0m
- Date: Tue, 22 Jan 2019 22:27:59 -0600
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FYjq9XAQHcxiPoUR5C6BzrcAvA0yDoejxcsngyX5OUo=; b=mtCBG3SGn8QdKL0jFGi5qDdYtQJcRkdwYUAfpMQFE+3irBozhwi1PK5nrResA4GGzy JxQ2QXbLHxwXBzSpmqqQCfAsj3WA3MKXySTHzI2OTlxfht0eWUgXhlhlGcZOkGD5IzI9 BPrxDbJdE1rDWAAbi/TW4Xa5P8yLbRgTDfUFSFnKzn4/uF+H/j50dYukmhjWElr9dXiF zLet7EgLpiZqwZVD4mpaBnsieMVHKkZWtCi2bjRfwb3bjTcm93GQ3KUAfDAAqqJUHE8H VrkKfLXpW7UKAogs/nL4zGTcmNqgZ9YR2KQEQ1P9FVnN6EIO11c6cML1aDMShNNopYdV Zzfg==
- In-reply-to: <CAKc7PVAcNJxUgDOshnJ0d8e5FNqF5c-scCST_ba0Fmr2uuv4_w@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVAcNJxUgDOshnJ0d8e5FNqF5c-scCST_ba0Fmr2uuv4_w@mail.gmail.com>
On 22 Jan 2019, at 09:27, Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
>phy1729 reports that OpenBSD doesn't include a leading 0m in its
>control codes output. Thus, X04 tests fail on that OS.
The failure is due to $termcap[me] on OpenBSD using \e(B\e[m where the test
expects \e[0m. After normalising to the latter and stripping \e(B from the
output, it passes. Fiddling about with hard-coded escape sequences feels
pretty brittle to me, but i guess that's what we're already doing, so...
hopefully it's at least better than just dropping the sequence entirely.
(I also fixed some white space; included as a separate diff below.)
Tested on macOS and OpenBSD. It passed for Matthew as well.
dana
diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst
index e14517490..9e3b2681b 100644
--- a/Test/X04zlehighlight.ztst
+++ b/Test/X04zlehighlight.ztst
@@ -29,6 +29,8 @@
integer i
for (( i = 0; i < ${1:-1}; ++i )); do
zpty -r zsh REPLY
+ # Normalise me/sgr0 to \e[0m. We also need to strip \e(B in zpty_stop()
+ REPLY=${REPLY//${termcap[me]}/$'\x1b[0m'}
# P is for "preserve", and induces keeping some
# expected color codes to test region_highlight,
# etc. - the color codes are made a regular text.
@@ -54,7 +56,7 @@
# zpty gives no output when piped without these braces (?)
# The while loop with // substitution is to convert `e^Mexit'
# into `exit' (see zpty_line). The sed commands remove escapes
- { zpty -r zsh } | sed -e $'/[^\t\r ]/!d' -e $'s/\r$//' -e $'s/\x1b\\[[0-9;]*m//g' | while read REPLY; do REPLY=${REPLY//(#b)((?(#c0,1))$cm(?(#c0,1)))/${${${(M)match[2]:#${match[3]}}:+${match[2]}}:-${${match[1]##[[:space:]]##}%%[[:space:]]##}}}; print -rn -- "$REPLY"; done
+ { zpty -r zsh } | sed -e $'/[^\t\r ]/!d' -e $'s/\r$//' -e $'s/\x1b\\[[0-9;]*m//g' -e $'s/\x1b([A-Z]//g' | while read REPLY; do REPLY=${REPLY//(#b)((?(#c0,1))$cm(?(#c0,1)))/${${${(M)match[2]:#${match[3]}}:+${match[2]}}:-${${match[1]##[[:space:]]##}%%[[:space:]]##}}}; print -rn -- "$REPLY"; done
zpty -d
:
}
diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst
index 9e3b2681b..b6a8c35fd 100644
--- a/Test/X04zlehighlight.ztst
+++ b/Test/X04zlehighlight.ztst
@@ -56,7 +56,12 @@
# zpty gives no output when piped without these braces (?)
# The while loop with // substitution is to convert `e^Mexit'
# into `exit' (see zpty_line). The sed commands remove escapes
- { zpty -r zsh } | sed -e $'/[^\t\r ]/!d' -e $'s/\r$//' -e $'s/\x1b\\[[0-9;]*m//g' -e $'s/\x1b([A-Z]//g' | while read REPLY; do REPLY=${REPLY//(#b)((?(#c0,1))$cm(?(#c0,1)))/${${${(M)match[2]:#${match[3]}}:+${match[2]}}:-${${match[1]##[[:space:]]##}%%[[:space:]]##}}}; print -rn -- "$REPLY"; done
+ { zpty -r zsh } |
+ sed -e $'/[^\t\r ]/!d' -e $'s/\r$//' -e $'s/\x1b\\[[0-9;]*m//g' -e $'s/\x1b([A-Z]//g' |
+ while read REPLY; do
+ REPLY=${REPLY//(#b)((?(#c0,1))$cm(?(#c0,1)))/${${${(M)match[2]:#${match[3]}}:+${match[2]}}:-${${match[1]##[[:space:]]##}%%[[:space:]]##}}}
+ print -rn -- "$REPLY"
+ done
zpty -d
:
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author