Package: ksh
Version: 93u-1
Severity: important


Traps set inside KSH functions and 'set -e' (exit on error) command
are ignored when the function is used in a command substitution
and the command substitution $( ) is contained in a || or && command,
or is following an 'if'. This problem does not occur in pdksh.


EXAMPLE:


#!/bin/ksh

function foo {
  set -e
  trap 'print "ERR trap of foo" > /dev/fd/2' ERR
  false  #false, having exit status 1, should execute the trap and then 
terminate foo()
  print 'we should not be here'
  return 0
}

print 'first try'
s=$(foo) || print 'foo returned with a non-zero exit status'
echo "($s)"


print 'second try'
s=$(foo)
echo "($s)"


OUTPUT (ksh):

first try
(we should not be here)
second try
ERR trap of foo
()


OUTPUT (pdksh):

first try
ERR trap of foo
foo returned with a non-zero exit status
()
second try
ERR trap of foo
()





-- System Information:
Debian Release: wheezy/sid
  APT prefers oneiric-updates
  APT policy: (500, 'oneiric-updates'), (500, 'oneiric-security'), (500, 
'oneiric'), (100, 'oneiric-backports')
Architecture: i386 (i686)

Kernel: Linux 3.0.0-13-generic (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages ksh depends on:
ii  libc6                     2.13-20ubuntu5 Embedded GNU C Library: Shared lib

ksh recommends no packages.

ksh suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to