>forgets to actually attach a diff... ;-)
Aaaaah! I already deleted the file so I had to do the annotating
all over again. Here you are.
Thanks for noticing,
//mirabilos
--
Gestern Nacht ist mein IRC-Netzwerk explodiert. Ich hatte nicht damit
gerechnet, darum bin ich blutverschmiert… wer konnte ahnen, daß SIE so
reagier’n… gestern Nacht ist mein IRC-Netzwerk explodiert~~~
(as of 2021-06-15 The MirOS Project temporarily reconvenes on OFTC)
‣ stop referring to dead IRC network (copied new file from upstream)
diff -pruN mksh-59c-8/FAQ2HTML.sh mksh-59c-9/FAQ2HTML.sh
--- mksh-59c-8/FAQ2HTML.sh 2020-10-31 05:18:03.000000000 +0100
+++ mksh-59c-9/FAQ2HTML.sh 2021-07-12 16:12:43.000000000 +0200
@@ -1,5 +1,5 @@
#!/bin/sh
-rcsid='$MirOS: src/bin/mksh/FAQ2HTML.sh,v 1.2 2020/10/31 04:17:36 tg Exp $'
+rcsid='$MirOS: src/bin/mksh/FAQ2HTML.sh,v 1.3 2021/06/15 01:09:43 tg Exp $'
#-
# Copyright © 2020
# mirabilos <m...@mirbsd.org>
@@ -109,7 +109,7 @@ cat <<EOF
}
/*]]>*/--></style>
</head><body>
-<p>Note: Links marked like <a href="irc://chat.freenode.net/!/bin/mksh">this
+<p>Note: Links marked like <a href="irc://irc.mirbsd.org/!/bin/mksh">this
one to the mksh IRC channel</a> connect to external resources.</p>
<p>⚠ <b>Notice:</b> the website will have <a
href="http://www.mirbsd.org/mksh-faq.htm">the latest version of the
‣ show error message and exit nōn-zero on stdout write failure
for builtin calls (Closes: #990265) → new tests
diff -pruN mksh-59c-8/check.t mksh-59c-9/check.t
--- mksh-59c-8/check.t 2021-07-12 16:13:08.000000000 +0200
+++ mksh-59c-9/check.t 2021-07-12 16:12:43.000000000 +0200
@@ -31,7 +31,7 @@
# (2013/12/02 20:39:44)
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
- KSH R59 2021/05/30
+ KSH R59 2021/07/10
description:
Check base version of full shell
stdin:
@@ -7896,6 +7896,77 @@ expected-stdout:
G 12
H 0
---
+name: exit-stdout-1
+description:
+ cf. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990265, Austin ML
+stdin:
+ if test -c /dev/full && test -w /dev/full; then
+ if pwd >/dev/full 2>e; then
+ cat e
+ echo fail
+ else
+ echo pass
+ fi
+ else
+ echo skip
+ fi
+ case " $(echo $( (set -o posix) >/dev/null 2>&1 && set -o posix
>/dev/null 2>&1; kill -l)) " in
+ (*' PIPE '*)
+ :>s
+ { trap '' PIPE; sleep 1; pwd 2>e; echo $? >s; } | :
+ case x$(cat s) in
+ (x)
+ cat e
+ echo fail else ;;
+ (x0)
+ cat e
+ echo fail 0 ;;
+ (*)
+ echo pass ;;
+ esac
+ ;;
+ (*)
+ echo skip ;;
+ esac
+expected-stdout-pattern:
+ /^(pass|skip)\n(pass|skip)\n$/
+---
+name: exit-stdout-2
+description:
+ same, except for external utility / direct builtin call
+stdin:
+ ln -s "$__progname" pwd || cp "$__progname" pwd
+ if test -c /dev/full && test -w /dev/full; then
+ if ./pwd >/dev/full 2>e; then
+ cat e
+ echo fail
+ else
+ echo pass
+ fi
+ else
+ echo skip
+ fi
+ case " $(echo $( (set -o posix) >/dev/null 2>&1 && set -o posix
>/dev/null 2>&1; kill -l)) " in
+ (*' PIPE '*)
+ :>s
+ { trap '' PIPE; sleep 1; ./pwd 2>e; echo $? >s; } | :
+ case x$(cat s) in
+ (x)
+ cat e
+ echo fail else ;;
+ (x0)
+ cat e
+ echo fail 0 ;;
+ (*)
+ echo pass ;;
+ esac
+ ;;
+ (*)
+ echo skip ;;
+ esac
+expected-stdout-pattern:
+ /^(pass|skip)\n(pass|skip)\n$/
+---
name: exit-trap-1
description:
Check that "exit" with no arguments behaves SUSv4 conformant.
‣ Update upstream contact info accordingly
diff -pruN mksh-59c-8/debian/README.Debian mksh-59c-9/debian/README.Debian
--- mksh-59c-8/debian/README.Debian 2021-05-31 02:40:08.000000000 +0200
+++ mksh-59c-9/debian/README.Debian 2021-07-10 22:06:04.000000000 +0200
@@ -16,12 +16,12 @@ in the Debian BTS; directly submit those
they may be ignored and closed if reported as Debian bugs. The
contact info for upstream is:
-* #!/bin/mksh (or #ksh) IRC channel
- at irc.freenode.net (Port 6697 SSL, 6667 unencrypted)
+* #!/bin/mksh IRC channel
+ at irc.oftc.net (Port 6697 SSL, 6667 unencrypted) currently
* mksh mailing list <miros-m...@mirbsd.org>
(does not require subscription to post)
- archived at http://news.gmane.org/gmane.os.miros.mksh and others
+ as GMane ended, there is no public archive any more, unfortunately
(note: several freemail providers have issues with the list;
use GMane (NNTP or web interface) to post in those cases)
diff -pruN mksh-59c-8/debian/changelog mksh-59c-9/debian/changelog
--- mksh-59c-8/debian/changelog 2021-05-31 02:42:55.000000000 +0200
+++ mksh-59c-9/debian/changelog 2021-07-10 22:08:30.000000000 +0200
@@ -1,3 +1,21 @@
+mksh (59c-9) unstable; urgency=medium
+
+ * Cherry-pick bugfixes from CVS HEAD:
+ - stop referring to dead IRC network
+ - check lower bounds of input line array when backspacing
+ - protect against hi-bit7 (stty) EOF character
+ - show error message and exit nōn-zero on stdout write failure
+ for builtin calls (Closes: #990265) + display correct errno
+ - show error message in echo/print builtin on output write failure
+ (it exits 1 already in that case)
+ - ensure macro calls don’t have side effects in arguments
+ - properly flush stderr and unwind for direct builtin calls
+ (“ln -s /bin/mksh echo; ./echo …”)
+ - fix truncation behaviour for internal snprintf equivalent
+ * Update upstream contact info accordingly
+
+ -- Thorsten Glaser <t...@mirbsd.de> Sat, 10 Jul 2021 22:08:30 +0200
+
mksh (59c-8) unstable; urgency=medium
* Fix a -Wpointer-sign in escaping code
‣ Update upstream contact info accordingly
diff -pruN mksh-59c-8/debian/upstream/metadata
mksh-59c-9/debian/upstream/metadata
--- mksh-59c-8/debian/upstream/metadata 2021-05-31 02:40:08.000000000 +0200
+++ mksh-59c-9/debian/upstream/metadata 2021-07-10 21:36:32.000000000 +0200
@@ -4,7 +4,7 @@
"Bug-Submit": "mailto:miros-m...@mirbsd.org",
"Changelog": "http://www.mirbsd.org/mksh.htm#clog",
"Cite-As": "The MirBSD Korn Shell (<a
href=\"http://www.mirbsd.org/mksh.htm\">mksh</a>)",
- "Contact": "irc://irc.freenode.net/!%2Fbin%2Fmksh",
+ "Contact": "irc://irc.oftc.net/!%2Fbin%2Fmksh",
"Documentation": "http://www.mirbsd.org/MirOS/dist/mir/mksh/mksh.pdf",
"Donation": "http://www.mirbsd.org/danke.htm",
"FAQ": "http://www.mirbsd.org/mksh-faq.htm",
‣ Hunk 1, 2: check lower bounds of input line array when backspacing
‣ Hunk 3: protect against hi-bit7 (stty) EOF character
diff -pruN mksh-59c-8/edit.c mksh-59c-9/edit.c
--- mksh-59c-8/edit.c 2021-07-12 16:13:08.000000000 +0200
+++ mksh-59c-9/edit.c 2021-07-12 16:12:43.000000000 +0200
@@ -1677,7 +1677,7 @@ static char *
x_bs0(char *cp, char *lower_bound)
{
if (UTFMODE)
- while ((!lower_bound || (cp > lower_bound)) &&
+ while ((cp > lower_bound) &&
((rtt2asc(*cp) & 0xC0) == 0x80))
--cp;
return (cp);
@@ -1688,7 +1688,7 @@ x_bs3(char **p)
{
int i;
- *p = x_bs0((*p) - 1, NULL);
+ *p = x_bs0((*p) - 1, xbuf);
i = x_size2(*p, NULL);
while (i--)
x_e_putc2('\b');
@@ -1843,10 +1843,11 @@ x_newline(int c MKSH_A_UNUSED)
static int
x_end_of_text(int c MKSH_A_UNUSED)
{
- unsigned char tmp[1], *cp = tmp;
+ unsigned char tmp[2], *cp = tmp;
*tmp = isedchar(edchars.eof) ? (unsigned char)edchars.eof :
(unsigned char)CTRL_D;
+ tmp[1] = '\0';
x_zotc3((char **)&cp);
x_putc('\r');
x_putc('\n');
‣ show error message and exit nōn-zero on stdout write failure
for builtin calls (Closes: #990265)
diff -pruN mksh-59c-8/exec.c mksh-59c-9/exec.c
--- mksh-59c-8/exec.c 2021-07-12 16:13:08.000000000 +0200
+++ mksh-59c-9/exec.c 2021-07-12 16:12:43.000000000 +0200
@@ -1397,7 +1397,11 @@ call_builtin(struct tbl *tp, const char
shl_stdout_ok = true;
ksh_getopt_reset(&builtin_opt, GF_ERROR);
rv = (*tp->val.f)(wp);
- shf_flush(shl_stdout);
+ if (shf_flush(shl_stdout) < 0) {
+ bi_errorf(Tf_sD_s, Twrite, cstrerror(errno));
+ if (rv == 0)
+ rv = 1;
+ }
shl_stdout_ok = false;
builtin_argv0 = NULL;
builtin_spec = false;
‣ Hunk 1: show error message in echo/print builtin on output write failure
‣ Hunk 2: ensure macro calls don’t have side effects in arguments
diff -pruN mksh-59c-8/funcs.c mksh-59c-9/funcs.c
--- mksh-59c-8/funcs.c 2021-07-12 16:13:08.000000000 +0200
+++ mksh-59c-9/funcs.c 2021-07-12 16:12:43.000000000 +0200
@@ -554,6 +554,7 @@ c_print(const char **wp)
po.copipe = block_pipe();
continue;
}
+ bi_errorf(Tf_sD_s, Twrite, cstrerror(errno));
c = 1;
break;
}
@@ -1134,7 +1135,8 @@ c_kill(const char **wp)
n = 1;
while (n < ksh_NSIG) {
shf_puts(sigtraps[n].name, shl_stdout);
- shf_putc(++n == ksh_NSIG ? '\n' : ' ',
+ ++n;
+ shf_putc(n == ksh_NSIG ? '\n' : ' ',
shl_stdout);
}
} else {
‣ stop referring to dead IRC network (copied new file from upstream)
diff -pruN mksh-59c-8/lksh.1 mksh-59c-9/lksh.1
--- mksh-59c-8/lksh.1 2020-09-05 00:37:28.000000000 +0200
+++ mksh-59c-9/lksh.1 2021-07-12 16:12:43.000000000 +0200
@@ -1,4 +1,4 @@
-.\" $MirOS: src/bin/mksh/lksh.1,v 1.26 2020/09/04 22:37:01 tg Exp $
+.\" $MirOS: src/bin/mksh/lksh.1,v 1.28 2021/06/15 13:20:05 tg Exp $
.\"-
.\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015, 2016, 2017, 2018
.\" mirabilos <m...@mirbsd.org>
@@ -81,7 +81,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
-.Dd $Mdocdate: September 4 2020 $
+.Dd $Mdocdate: June 15 2021 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"
@@ -346,16 +346,12 @@ Talk to the
.Mx
development team and users using the mailing list at
.Aq Mt miros\-m...@mirbsd.org
-(please note the EU-DSGVO/GDPR notice on
-.Pa http://www.mirbsd.org/rss.htm#lists
-and in the SMTP banner!) or the
+or in the
.Li \&#\&!/bin/mksh
-.Pq or Li \&#ksh
-IRC channel at
-.Pa irc.freenode.net
-.Pq Port 6697 SSL, 6667 unencrypted
-if you need any further quirks or assistance,
-and consider migrating your legacy scripts to work with
+IRC channel; mind the infos from
+.Pa http://www.mirbsd.org/mksh\-faq.htm#contact
+for either.
+Consider migrating your legacy scripts to work with
.Nm mksh
instead of requiring
.Nm .
‣ properly flush stderr and unwind for direct builtin calls
diff -pruN mksh-59c-8/main.c mksh-59c-9/main.c
--- mksh-59c-8/main.c 2021-07-12 16:13:08.000000000 +0200
+++ mksh-59c-9/main.c 2021-07-12 16:12:43.000000000 +0200
@@ -738,6 +738,9 @@ main(int argc, const char *argv[])
if ((rv = main_init(argc, argv, &s, &l)) == 0) {
if (as_builtin) {
rv = c_builtin(l->argv);
+ exstat = rv & 0xFF;
+ unwind(LEXIT);
+ /* NOTREACHED */
} else {
shell(s, 0);
/* NOTREACHED */
‣ stop referring to dead IRC network
‣ indicate we have Debian-specific patches
diff -pruN mksh-59c-8/mksh.1 mksh-59c-9/mksh.1
--- mksh-59c-8/mksh.1 2021-07-12 16:13:08.000000000 +0200
+++ mksh-59c-9/mksh.1 2021-07-12 16:12:43.000000000 +0200
@@ -1,4 +1,4 @@
-.\" $MirOS: src/bin/mksh/mksh.1,v 1.506+locale-tracking 2021/02/26 11:51:08 tg
Exp $
+.\" $MirOS: src/bin/mksh/mksh.1,v 1.507+1.512+locale-tracking 2021/05/02
16:57:53 tg Exp $
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
.\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
@@ -84,7 +84,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
-.Dd $Mdocdate: May 2 2021 $
+.Dd $Mdocdate: July 10 2021 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"
@@ -7141,7 +7141,7 @@ for the in-memory portion of the history
This document attempts to describe
.Nm mksh\ R59-CURRENT
and up,
-.\" with vendor patches from insert-your-name-here,
+with vendor patches from Debian,
compiled without any options impacting functionality, such as
.Dv MKSH_SMALL ,
when not called as
@@ -7157,13 +7157,7 @@ Please report bugs in
.Nm
to the public development mailing list at
.Aq Mt miros\-m...@mirbsd.org
-(please note the EU-DSGVO/GDPR notice on
-.Pa http://www.mirbsd.org/rss.htm#lists
-and in the SMTP banner!) or in the
+or, in the
.Li \&#\&!/bin/mksh
-.Pq or Li \&#ksh
-IRC channel at
-.Pa irc.freenode.net
-.Pq Port 6697 SSL, 6667 unencrypted ,
-or at:
-.Pa https://launchpad.net/mksh
+channel, on IRC; for both, note the information at:
+.Pa http://www.mirbsd.org/mksh\-faq.htm#contact
‣ stop referring to dead IRC network (copied new file from upstream)
‣ (also copied the new section about quoting; the corresponding
code change is in testing already)
diff -pruN mksh-59c-8/mksh.faq mksh-59c-9/mksh.faq
--- mksh-59c-8/mksh.faq 2021-07-12 16:13:08.000000000 +0200
+++ mksh-59c-9/mksh.faq 2021-07-12 16:12:43.000000000 +0200
@@ -1,4 +1,4 @@
-RCSID: $MirOS: src/bin/mksh/mksh.faq,v 1.19+locale-tracking 2021/05/02
08:26:03 tg Exp $
+RCSID: $MirOS: src/bin/mksh/mksh.faq,v 1.23+locale-tracking 2021/07/10
17:39:27 tg Exp $
ToC: spelling
Title: How do you spell <tt>mksh</tt>? How do you pronounce it?
@@ -101,8 +101,8 @@ Title: How does this relate to ksh or th
getting close to, ksh88 compatibility.</p>
<p>SKsh is an AmigaOS-specific Korn Shell-lookalike by Steve Koren.</p>
<p>The <a href="@@RELPATH@@ksh-chan.htm">Homepage of the <tt>#ksh</tt>
- channel on Freenode IRC</a> contains more information about the Korn
- Shell in general and its flavours.</p>
+ channel on IRC</a> contains more information about the Korn Shell in
+ general and its flavours.</p>
----
ToC: packaging
Title: How should I package mksh? (common cases)
@@ -346,6 +346,27 @@ Title: Multiline command editing
nōn-zero (e.g. using jupp’s “abendjoe” command) to prevent execution.
This is <em>really</em> useful to write ad-hōc scripts as well.</p>
----
+ToC: escaping
+Title: Some characters don’t display right
+
+<p>First, make sure that either you’re using a UTF-8 terminal and system
+ and the shell’s UTF-8 mode is on (<tt>set -U</tt>) or that you’re using
+ an 8-bit codepage/CCSID and the UTF-8 mode is off (<tt>set +U</tt>). If
+ you’re on an EBCDIC system ensure to pick a codepage that has a bijective
+ mapping to (Extended) ASCII and in which all necessary characters are
+ present, for example 1047. Furthermore ensure the compile-time and runtime
+ codepages match. (Other encoding schemes, e.g. DBCS or ISO-2022-JP, are
+ not supported.) This should already fix most relevant issues.</p>
+<p>If using an 8-bit coding system that (unlike e.g. ISO 8859 or EBCDIC)
+ does not assign control characters to “Extended ASCII” codepoints 0x80‥0x9F,
+ such as codepages 437, 850, 1252, … (usually on OS/2 or DOS-based systems),
+ enable the option <tt>set -o asis</tt> (new in R60); otherwise, they will
+ be escaped to avoid accidentally setting off terminal control sequences.</p>
+<p>Note that escaping of characters is, at runtime, dependent on whether the
+ shell was compiled for EBCDIC and/or <tt>utf8-mode</tt> and/or <tt>asis</tt>
+ are enabled, the latter being ignored if either of the former two are true
+ (in UTF-8 mode, UCS C1 codepoints are always escaped).</p>
+----
ToC: ctrl-l-cls
Title: ^L (Ctrl-L) does not clear the screen
@@ -697,18 +718,22 @@ Title: I use “set -eo pipefail” and
ToC: faq
Title: My question is not answered here!
-Do read the mksh(1) manual page. You might also wish to read the <a
- href="@@RELPATH@@ksh-chan.htm">homepage of the <tt>#ksh</tt> IRC channel
-on Freenode</a> which lists several resources for Korn or POSIX-compatible
-shells in general. Or, <a href="#contact">contact</a> us (developer and
-users), for example via IRC.
+Do read the mksh(1) and lksh(1) manual page. You might also wish to read the <a
+ href="@@RELPATH@@ksh-chan.htm">homepage of the <tt>#ksh</tt> IRC channel</a>
+which lists several resources for Korn or POSIX-compatible shells in general.
+Or, <a href="#contact">contact</a> us (developer and users).
----
ToC: contact
-Title: How do I contact you (to say thanks)?
+Title: How do I contact you (to say thanks, for bugreports and questions)?
-You can say hi in the <tt>#!/bin/mksh</tt> channel on Freenode <a
- href="@@RELPATH@@irc.htm">IRC</a>, although a <a
- href="@@RELPATH@@danke.htm">donation</a> wouldn’t be amiss ☺ The <a
- href="http://www.mail-archive.com/miros-mksh@mirbsd.org/">mailing
-list</a> can also be used.
+<p>You can say hi in the <tt>#!/bin/mksh</tt> channel on <a
+ href="@@RELPATH@@irc.htm">IRC</a> (OFTC, for now), although… a
+ <a href="@@RELPATH@@danke.htm">donation</a> wouldn’t be amiss ☻
+<br />The <a href="@@RELPATH@@rss.htm#lists">mailing list</a> can also
+ be used for this. The <a href="#faq">extra resources</a> from the FAQ
+ entry just one above should also be considered ;-)</p>
+<p>If you insist on sending a bugreport, IRC and the mailing list are
+ great places for that; <a href="https://launchpad.net/mksh">Launchpad</a>,
+ an external gratis service provided by a company, can also be used if you
+ like web-based issue trackers better.</p>
----
‣ bump version
diff -pruN mksh-59c-8/sh.h mksh-59c-9/sh.h
--- mksh-59c-8/sh.h 2021-07-12 16:13:08.000000000 +0200
+++ mksh-59c-9/sh.h 2021-07-12 16:12:43.000000000 +0200
@@ -195,7 +195,7 @@
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.906 2021/01/24 19:37:31 tg Exp $");
#endif
-#define MKSH_VERSION "R59 2021/05/30"
+#define MKSH_VERSION "R59 2021/07/10"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES
‣ Hunk 1: ensure shf_emptybuf callers don’t lose errno in one codepath
(needed for the stdout write failure checks)
‣ Hunk 2: fix truncation behaviour for internal snprintf equivalent
‣ Hunk 3: ensure macro calls don’t have side effects in arguments
diff -pruN mksh-59c-8/shf.c mksh-59c-9/shf.c
--- mksh-59c-8/shf.c 2021-07-12 16:13:08.000000000 +0200
+++ mksh-59c-9/shf.c 2021-07-12 16:12:43.000000000 +0200
@@ -383,6 +383,8 @@ shf_emptybuf(struct shf *shf, int flags)
memmove(shf->buf, buf,
ntowrite);
shf->wp = shf->buf + ntowrite;
+ /* restore errno for caller */
+ errno = shf->errnosv;
}
return (-1);
}
@@ -681,8 +683,13 @@ shf_write(const char *buf, ssize_t nbyte
if (shf->flags & SHF_STRING) {
/* resize buffer until there's enough space left */
while (nbytes > shf->wnleft)
- if (shf_emptybuf(shf, EB_GROW) == -1)
- return (-1);
+ if (shf_emptybuf(shf, EB_GROW) == -1) {
+ /* truncate if possible */
+ if (shf->wnleft == 0)
+ return (-1);
+ nbytes = shf->wnleft;
+ break;
+ }
/* then write everything into the buffer */
} else {
/* flush deals with sticky errors */
@@ -1063,8 +1070,7 @@ shf_vfprintf(struct shf *shf, const char
nwritten += precision;
precision = utf_skipcols(s, precision, &tmp) - s;
- while (precision--)
- shf_putc(*s++, shf);
+ shf_write(s, precision, shf);
nwritten += field;
while (field--)