Your message dated Tue, 16 Nov 2010 14:32:53 +0000
with message-id <[email protected]>
and subject line Bug#599484: fixed in mksh 39.3.20101101-1
has caused the Debian Bug report #599484,
regarding mksh: make "exit" without argument in trap more useful
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
599484: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=599484
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: mksh
Version: 39.3.20100725-1
Severity: normal
Justification: posix [1]

It is handy to be able to use the old exit status from an EXIT handler
by using bare "exit":

 $ sh -c 'trap "echo hi; exit" EXIT; exit 9'; echo $?
 hi
 9

Maybe something like the following would do the trick?  Untested, does
not handle nested traps.

[1] 
http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_21_14
http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_24_14
---
diff --git a/funcs.c b/funcs.c
index 4ec5dab..859c7a4 100644
--- a/funcs.c
+++ b/funcs.c
@@ -2247,6 +2247,9 @@ c_exitreturn(const char **wp)
                        warningf(true, "%s: bad number", arg);
                } else
                        exstat = n;
+       } else {
+               if (trap_exstat != -1)
+                       exstat = trap_exstat;
        }
        if (wp[0][0] == 'r') { /* return */
                struct env *ep;
diff --git a/histrap.c b/histrap.c
index 2ac4c38..9bcfb98 100644
--- a/histrap.c
+++ b/histrap.c
@@ -1048,6 +1048,8 @@ inittraps(void)
        int i;
        const char *cs;
 
+       trap_exstat = -1;
+
        /* Populate sigtraps based on sys_signame and sys_siglist. */
        for (i = 0; i <= NSIG; i++) {
                sigtraps[i].signal = i;
@@ -1263,7 +1265,6 @@ runtrap(Trap *p)
 {
        int     i = p->signal;
        char    *trapstr = p->trap;
-       int     oexstat;
        int     old_changed = 0;
 
        p->set = 0;
@@ -1287,13 +1288,14 @@ runtrap(Trap *p)
                p->flags &= ~TF_CHANGED;
                p->trap = NULL;
        }
-       oexstat = exstat;
+       trap_exstat = exstat;
        /*
         * Note: trapstr is fully parsed before anything is executed, thus
         * no problem with afree(p->trap) in settrap() while still in use.
         */
        command(trapstr, current_lineno);
-       exstat = oexstat;
+       exstat = trap_exstat;
+       trap_exstat = -1;
        if (i == SIGEXIT_ || i == SIGERR_) {
                if (p->flags & TF_CHANGED)
                        /* don't clear TF_CHANGED */
diff --git a/sh.h b/sh.h
index 640add0..cfa7460 100644
--- a/sh.h
+++ b/sh.h
@@ -557,6 +557,7 @@ EXTERN struct mksh_kshstate_v {
        /* global state */
        pid_t procpid_;         /* PID of executing process */
        int exstat_;            /* exit status */
+       int trap_exstat_;       /* exit status that triggered trap */
        int subst_exstat_;      /* exit status of last $(..)/`..` */
        struct env env_;        /* top-level parsing & execution env. */
        uint8_t shell_flags_[FNFLAGS];
@@ -576,6 +577,7 @@ EXTERN struct mksh_kshstate_f {
 #define ksheuid                kshstate_f.ksheuid_
 #define kshppid                kshstate_f.kshppid_
 #define exstat         kshstate_v.exstat_
+#define trap_exstat    kshstate_v.trap_exstat_
 #define subst_exstat   kshstate_v.subst_exstat_
 
 /* evil hack: return hash(kshstate_f concat (kshstate_f'.h:=hash(arg))) */



--- End Message ---
--- Begin Message ---
Source: mksh
Source-Version: 39.3.20101101-1

We believe that the bug you reported is fixed in the latest version of
mksh, which is due to be installed in the Debian FTP archive:

mksh_39.3.20101101-1.diff.gz
  to main/m/mksh/mksh_39.3.20101101-1.diff.gz
mksh_39.3.20101101-1.dsc
  to main/m/mksh/mksh_39.3.20101101-1.dsc
mksh_39.3.20101101-1_i386.deb
  to main/m/mksh/mksh_39.3.20101101-1_i386.deb
mksh_39.3.20101101.orig.tar.gz
  to main/m/mksh/mksh_39.3.20101101.orig.tar.gz



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Thorsten Glaser <[email protected]> (supplier of updated mksh package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA384

Format: 1.8
Date: Tue, 16 Nov 2010 13:42:18 +0000
Source: mksh
Binary: mksh
Architecture: source i386
Version: 39.3.20101101-1
Distribution: unstable
Urgency: low
Maintainer: Thorsten Glaser <[email protected]>
Changed-By: Thorsten Glaser <[email protected]>
Description: 
 mksh       - MirBSD Korn Shell
Closes: 599484 601925
Changes: 
 mksh (39.3.20101101-1) unstable; urgency=low
 .
   * New CVS snapshot:
     - [tg] In setres{u,g}id/setuid EAGAIN case, error out immediately
     - [OpenBSD] Some small manpage fixes
     - [tg] Clean up mirtoconf and build warnings with some compilers
     - [tg] Fix \c? vs. \c~ mis-documentation in mksh(1)
     - [tg] Remove the somewhat-portable setmode.c from the mksh source
       distribution and demote mknod(8) to an optional builtin, disabled
       by default, manually re-enabled in the installer only on MirBSD
     - [tg] Regenerate wcwidth table from Unicode 6.0.0
     - [tg] Change behaviour of argument-less exit in traps to match SUSv4,
       original patch from Jonathan Nieder (Debian Closes: #599484)
   * Integrate Vietnamese translation update, thanks Clytie Siddall
     (Closes: #601925)
   * Use lsb-release instead of dpkg-vendor for better reliability
 .
 mksh (39.3.20100915-1) UNRELEASED; urgency=high
 .
   * New CVS snapshot:
     - [Jeff Hamilton] Don’t alias stop on Android (system specific conflict)
     - [tg] Add size optimisations, ifdef’d, mostly for Android
     - [tg] Address what few concerns Chris Palmer (Android security team) had:
       check all multiplications and some additions for integer overflows,
       mostly in allocation context, and check setres{u,g}id/setuid for EAGAIN
       iff the target OS is known to be returning it (Linux only, right now)
     - correct a regression: 「read i?'foo:'」 was not working
 .
 mksh (39.3.20100905-1) UNRELEASED; urgency=low
 .
   * New CVS snapshot:
     - [tg] More int → bool conversion, whitespace and related code cleanup
     - [tg] Improve mksh(1) manpage coverage, remove mentions of not-mksh
     - [tg] Use wcwidth() from system on MirBSD
     - [tg] u_int32_t is no longer needed (only for OpenBSD’s pre-ISO-C99
       arc4random API, which we no longer call), so don’t provide it from
       Build.sh any longer
     - [tg, tonnerre] Scan for uint8_t and provide if not found
     - [tg] Fix realpath builtin for “/file/” arguments wrt. POSIX
     - [tg] Do not generate <stdint.h> from Build.sh as file any more if
       it is missing; rather let sh.h define the types appropriately and
       fix related compiler warnings
     - [tg] Add “cat” builtin (defers to external if options are given)
     - [tg] Reduce size by improved string pooling
     - [tg] Document 「x=$(eval $(cat)) <<'EOF'」 workaround for the $(…)
       parsing bug in the mksh(1) manual page and on the Red Hat Bugzilla
     - [tg] Add support for handling a “--” argument to more builtins
     - [tg] Correct some error messages
   * Move extra/printf.c.1.nn to debian/extra/printf.c for improved
     compatibility with source/format 3.0 and reduced build warnings
   * Build with -Wall -Wextra in all modes
   * Mention where strict aliasing warnings in dietlibc mode come from
Checksums-Sha1: 
 e60fbac6446c840f46b2789fca2aa0e997cd88f2 1932 mksh_39.3.20101101-1.dsc
 3c15bf685a10b7530651feda9a2f3fc7fd719234 302326 mksh_39.3.20101101.orig.tar.gz
 4662eeefad2d59df36521fce25bd6c0b16a2d1d1 60520 mksh_39.3.20101101-1.diff.gz
 5f7ce4fa993e392d7c0a13c2f518525ccfc4c887 311804 mksh_39.3.20101101-1_i386.deb
Checksums-Sha256: 
 6b369701b01ec2d3098e4fc2dbdf63568b4d9a0f8516e0b09ad7ff85c08356a2 1932 
mksh_39.3.20101101-1.dsc
 829fff820e22020d06db2399126d783942bccdf948bb35f5fa721546eebf5b3c 302326 
mksh_39.3.20101101.orig.tar.gz
 55853d2b7e154669674936322b6c459363db66da471cc64f93e3f409bc499901 60520 
mksh_39.3.20101101-1.diff.gz
 e394a2ff2d59976481088f0a8ced6691e4b7817262aa51ab11c961b7279fddea 311804 
mksh_39.3.20101101-1_i386.deb
Files: 
 6195d2e541c3b962081220d3c1382582 1932 shells optional mksh_39.3.20101101-1.dsc
 e2dcd70f0a1d3ab94a31112172638fa5 302326 shells optional 
mksh_39.3.20101101.orig.tar.gz
 b95d5924a2b73a826b1c66889920b6d5 60520 shells optional 
mksh_39.3.20101101-1.diff.gz
 6feb5c0cfd4344682867fe67ee184f47 311804 shells optional 
mksh_39.3.20101101-1_i386.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MirBSD)

iQIVAwUBTOKSQ3a1NLLpkAfgAQn8rRAAqQ0Idcs/RvW4W0hV2gVTWB78dp47fwUl
TNxlus4QPYAr61jZVtSn3ESroOy/EtAmFJrSZR1vo8ZmBf+kI+FwGKBV4Aai0gxa
lVT8Xlcup4edtNsM40qAKZWvBn8M2v3qdPTpK84j09CdCyILSjZI/gOPtNs6e9s1
unPpfjPMfk1O0dhQ9tWmsZGcsvTeBSNlgHlgZVo9DroTNxoM7ITxV63ffZ1VzztW
s0MpCKRdAAFN6/Iws5fitmhzWt9X06/GacbnlCsiGcmxNSxYzWQED12lw9Z9cbeM
Vk1PqOXYbSBOGmDL2il1tSI38QnALVNI3FTwAqLmbrLAgGP/2qZVPyTd/I52qKv9
w1uIp1iqpaUanqhM6mPgUyxv3zNgZ9xtWuVZ0FXNdk2NLGGNsf+xHYQn1piH+T/y
PZcVCViHHdrNKq54WFLaKq1F/ZWl52mySt/+3IhquVs1Fixfme0YuJUpOOjyP3+Q
j6G5nVrBO5IO3sohmrhPXaqNCW82FHMq3LCdEePRBpAKPEou/D3hhVl2PzxAyOnH
Es0yK3f/U/b7ENOkRPKIhxRR8Otbm+tmVUJMFfalbvRi5HB1Gaj00DCFb78aGlNW
eJvYSu5vWOko3jgu22xeStpddJMpuXah7CPEyeyVIjLVNsA4ECvC2vo4S6nj8TD/
RsGIPnqRMNw=
=faT2
-----END PGP SIGNATURE-----



--- End Message ---

Reply via email to