$ mksh -c 'trap "" CONT; trap'
trap --  CONT

That is not "suitable for re-entry into the shell". Empties must be
quoted, or they disappear. Expected output:

trap -- '' CONT

Here's a patch.

Index: misc.c
===================================================================
RCS file: /cvs/src/bin/mksh/misc.c,v
retrieving revision 1.291
diff -u -r1.291 misc.c
--- misc.c      14 Jan 2018 00:03:03 -0000      1.291
+++ misc.c      17 Mar 2018 12:03:42 -0000
@@ -1346,7 +1346,14 @@
        const unsigned char *p = (const unsigned char *)s;
        bool inquote = true;

-       /* first, check whether any quotes are needed */
+       /* first, check for empty */
+       if (*p == '\0') {
+               shf_putc('\'', shf);
+               shf_putc('\'', shf);
+               return;
+       }
+
+       /* non-empty: check whether any quotes are needed */
        while (rtt2asc(c = *p++) >= 32)
                if (ctype(c, C_QUOTE | C_SPC))
                        inquote = false;

Reply via email to