Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-Server-Uuid: 95b8ca9b-fe4b-44f7-8977-a6cb2d3025ff Message-ID: From: "Moreland, Kenneth" To: "'cygwin AT cygwin DOT com'" Subject: ash-20010805-1 calling trap incorrectly. Date: Thu, 23 Aug 2001 11:41:16 -0600 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) X-Filter-Version: 1.3 (sass165) X-WSS-ID: 179BE0D11528662-01-01 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit 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 <> out trap 0 echo "Trap cleared." >> out cat out When run with the latest version of the shell script, the output is: hello 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: hello 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. -Ken **** Kenneth Moreland *** Sandia National Laboratories *********** *** *** *** email: kmorel AT sandia DOT gov ** *** ** phone: (505) 844-8919 *** fax: (505) 844-9297 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/