Module Name: src Committed By: kre Date: Sat Apr 29 15:12:21 UTC 2017
Modified Files: src/bin/sh: trap.c var.c Log Message: Fix several problems with the implementation of the "trap" command (that is, with the command itself, not with the traps that are executed, if any). - "trap -- -l" is not rational, permit the (non-std) -l option only when given as the sole arg (ie: "trap -l"). - "trap --" is the same as just "trap" (and -- is ignored for below) - "trap action" generates a usage message (there must be at least one condition) - "trap N [condition...]" (the old form with a numeric first arg, to reset traps to default, instead of "trap - condition...") is properly detected. In particular while "trap 1 2 3" resets sighup sigint and siquit handlers to default, "trap hup int quit" runs the "hup" command on sigint or sigquit and does nothing to sighup at all. - actions can start with "-" (as can commands in general) - it may be unusual or even unwise, but it is not prohibited, and should work - bad conditions (signal names/numbers) are just a usage error (resulting in non-zero "exit status" (and a diagnostic on stderr)) they do not cause the script to abort (as a syntax error in a special builtin would.) (so says posix, very explicitly.) - when outputting the trap list ("trap") properly quote null actions (ignored conditions). This has the side effect of also generating an explicit null string ('') in other cases where null values are output, such as when reporting var values ("set") but that's OK, and might be better (VAR= and VAR='' mean the same, but the latter is more obvious.) We still do not properly handle traps=$(trap) (ie: it does not work at all, and should) but that's a different problem that needs fixing in another place. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/bin/sh/trap.c cvs rdiff -u -r1.49 -r1.50 src/bin/sh/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.