This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ash-20010805-1 calling trap incorrectly.

I've recently installed cygwin on Windows 2000 and noticed a problem with
sh, specifically the sh included in ash-20010805-1.tar.bz2.  When using the
<< form of redirection AND using a `command || command` command substitution
within the text of the redirection where the first command is not a shell
built in, the trap for signal 0 is called.  The trap appears to be called in
a subshell of some sort because it cannot affect the standard output or
error streams nor can it change any shell variables.  However, its effects
can be seen indirectly through the manipulation of files.  As an example,
consider the following shell script:

#! /bin/sh

rm -f out

trap "echo Caught trap! >> out" 0

echo "Before cat." > out

cat <<EOF
`/bin/echo hello || /bin/echo world`

echo "After cat." >> out

trap 0

echo "Trap cleared." >> out

cat out

When run with the latest version of the shell script, the output is:

Before cat.
Caught trap!
After cat.
Trap cleared.

As you can see, the signal 0 is somehow raised in the cat command and
"Caught trap!" is inserted into the file out.  When I back out of the latest
version of ash to ash-20010425.tar.gz, I get the correct output:

Before cat.
After cat.
Trap cleared.

I first noticed this bug while using autoconf and libtool.  The
AC_PROG_LIBTOOL macro generated script code with the described conditions,
which caused a trap command to be called that deleted a header file which
subsequent compiler tests depended on.


   ****      Kenneth Moreland
    ***      Sandia National Laboratories
*** *** ***  email:
**  ***  **  phone: (505) 844-8919
    ***      fax:   (505) 844-9297

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]