Subject: bin/15544: /bin/sh trap command not POSIX compliant
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jon@bullers.net>
List: netbsd-bugs
Date: 02/08/2002 16:19:18
>Number:         15544
>Category:       bin
>Synopsis:       /bin/sh trap command does not accept signal names
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 08 16:20:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jon Buller
>Release:        NetBSD 1.5.3_ALPHA  20020122 (or there abouts)
>Organization:
>Environment:
System: NetBSD bullball.bullers.net 1.5.3_ALPHA NetBSD 1.5.3_ALPHA (BULLBALL) #1: Tue Jan 8 21:51:41 PST 2002 jon@bullball.bullers.net:/usr/src/sys/arch/sparc/compile/BULLBALL sparc
Architecture: sparc
Machine: sparc
>Description:
	cat << EOF > foo
#!/bin/sh

trap "echo trapped" INT

exit 0
	EOF
	chmod 755 foo
	./foo

What you get is the message "trap: Illegal number: INT"

I was told this in relation to the problem:

	  It appears that your shell does not permit symbolic signal
	  names? They are required by Posix and the only work-around,
	  using numeric signal names, is only permitted -- not
	  required by Posix.

>How-To-Repeat:
	see above
>Fix:
	Work around by using ksh.  I think the fix needs to be made
	on line 110 of /usr/src/bin/sh/trap.c  (rev 1.24.4.2) by
	making is_number() also recognize signal names.  Line 115
	also needs to be fixed to return the signal number when
	number() is given a string with the proper name.
>Release-Note:
>Audit-Trail:
>Unformatted: