Package: bash
Version: 3.1-4
Severity: normal

i'm experimenting with the DEBUG trap.  There has been a regression
since sarge's bash version in how it interacts with bash's job list.
It appears that in bash 3.1.14, bash overwrites each job's title
string with the contents of the DEBUG trap itself, rather than
retaining the job's own invocation string.

in the transcripts below, i'll put ^Z to mean pressing ctrl-Z (even
though it doesn't actually show up in the terminal).  Likewise with
^D for the EOF.

with nothing in the DEBUG trap (this is good, and the expected
behavior!):

[0 [EMAIL PROTECTED] ~]$ trap - DEBUG
[0 [EMAIL PROTECTED] ~]$ cat
^Z
[1]+  Stopped                 cat
[148 [EMAIL PROTECTED] ~]$ jobs
[1]+  Stopped                 cat
[0 [EMAIL PROTECTED] ~]$ fg
cat
^D
[0 [EMAIL PROTECTED] ~]$ 


on a sarge system (this is also the behavior i expect):

[0 [EMAIL PROTECTED] dkg]$ bash --version
GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.
[0 [EMAIL PROTECTED] dkg]$ trap "echo foo" DEBUG
[0 [EMAIL PROTECTED] dkg]$ cat
foo
^Z
[1]+  Stopped                 cat
[0 [EMAIL PROTECTED] dkg]$ jobs
foo
[1]+  Stopped                 cat
[0 [EMAIL PROTECTED] dkg]$ fg
foo
cat
^D
[0 [EMAIL PROTECTED] dkg]$ 


But the job listings are screwed up by the DEBUG trap on an etch
version of bash.  Note how the job is listed with the string of the
DEBUG command, rather than the job's own command:

[0 [EMAIL PROTECTED] ~]$ bash --version
GNU bash, version 3.1.14(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
[0 [EMAIL PROTECTED] ~]$ trap "echo foo" DEBUG
[0 [EMAIL PROTECTED] ~]$ cat
foo
^Z
[1]+  Stopped                 echo foo
[148 [EMAIL PROTECTED] ~]$ jobs
foo
[1]+  Stopped                 echo foo
[0 [EMAIL PROTECTED] ~]$ fg
foo
echo foo
^D
[0 [EMAIL PROTECTED] ~]$ 

Note that this problem doesn't seem to occur if you launch jobs that
are directly backgrounded.  For example:

[0 [EMAIL PROTECTED] ~]$ trap "echo foo" DEBUG
[0 [EMAIL PROTECTED] ~]$ long-running-job &
foo
[1] 16522
[127 [EMAIL PROTECTED] ~]$ jobs
foo
[1]+  Running                 long-running-job &
[0 [EMAIL PROTECTED] ~]$ 


but it does effect jobs that are explicitly backgrounded later on:

[0 [EMAIL PROTECTED] ~]$ trap "echo foo" DEBUG
[0 [EMAIL PROTECTED] ~]$ long-running-job
foo
^Z
[1]+  Stopped                 echo foo
[148 [EMAIL PROTECTED] ~]$ bg
foo
[1]+ echo foo &
[0 [EMAIL PROTECTED] ~]$ jobs
foo
[1]+  Running                 echo foo &
[0 [EMAIL PROTECTED] ~]$ 


Perhaps this means that it is the suspend character itself causing the
munging to take place -- i'm not sure.  At any rate, a broken jobs
table is the result, which could cause some headaches later on.

Let me know if i can do anything to help debug this further.

        --dkg



-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages bash depends on:
ii  base-files                    3.1.13     Debian base system miscellaneous f
ii  debianutils                   2.16.1     Miscellaneous utilities specific t
ii  libc6                         2.3.6-7    GNU C Library: Shared libraries
ii  libncurses5                   5.5-2      Shared libraries for terminal hand

bash recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to