Skip to content

Some bugs and crashes when using the DEBUG trap #155

@ko1nksm

Description

@ko1nksm

Tested with ksh Version AJMv 93u+m/1.0.0-alpha+ccd98fe7 2021-01-08 on Ubuntu 20.04

1. Redirecting disables the DEBUG trap

edit: fixed in 2a835a2, e664b78

trap 'echo LINENO: $LINENO >&1' DEBUG # 1 
echo foo                              # 2
var=$(echo)                           # 3
echo bar                              # 4
echo baz                              # 5

Expected (This is what happens when you remove >&1).

LINENO: 2
foo
LINENO: 3
LINENO: 4
bar
LINENO: 5
baz

Actual

LINENO: 2
foo
bar
baz

2. Crashes when re-trapping inside a subshell

edit: fixed in 2a835a2

set -e
trap ':' DEBUG
( trap ':' DEBUG )
echo ok
ksh.sh[22]: ^P?`?^X?%?d�: not found [No such file or directory]

3. The split word will not work

edit: fixed in 70368c5

v=''
trap ': $v' DEBUG
A="a b c"
set -- $A
printf '%s\n' "$@"

Expected

a
b
c

Actual

a b c

4. Side effects to exit status

edit: fixed in d00b4b3

trap ':' DEBUG

(exit 123)
echo $? # => 123 (Correct)

r=$(exit 123)
echo $? # => Same as above, expected 123, but actually 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions