Invalid signal used with trap causes dash to abort

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

there seems to be a problem  with the trap implementation in dash
(tested with 0.5.4 and 0.5.5.1). If I specify a signal which is not 
supported, the shell unconditionally aborts. E.g., I had expected
the following to print foo (like bash and zsh do):

# dash -c 'trap "echo trap executed" UNKNOWNSIGNAL || echo "foo"'
trap: 1: UNKNOWNSIGNAL: bad trap

This means I cannot write a construct like the following to take 
advantage of the ERR signal which is present in some shells:

trap "echo ERR trap executed" ERR 2>/dev/null || :

I also checked the POSIX documentation, and quoting from
http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html
(exit status): "For both interactive and non-interactive shells, 
invalid signal names [XSI] [Option Start] or numbers [Option End] 
shall not be considered a syntax error and do not cause the shell 
to abort."

Best regards,
//Peter

--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux