for (signo = 0; signo < NSIG; signo++) {
char *tr = trap_ptr[signo];
if (tr) {
- out1fmt("trap -- %s %s%s\n",
+ /* note: bash adds "SIG", but only if invoked
+ * as "bash". If called as "sh", or if set -o posix,
+ * then it prints short signal names.
+ * We are printing short names: */
+ out1fmt("trap -- %s %s\n",
single_quote(tr),
- (signo == 0 ? "" : "SIG"),
get_signame(signo));
/* trap_ptr != trap only if we are in special-cased `trap` code.
* In this case, we will exit very soon, no need to free(). */
- /* if (trap_ptr != trap) */
+ /* if (trap_ptr != trap && tp[0]) */
/* free(tr); */
}
}
trap -- 'echo Exiting' EXIT
-trap -- 'echo WINCH!' SIGWINCH
+trap -- 'echo WINCH!' WINCH
trap -- 'echo Exiting' EXIT
-trap -- 'echo WINCH!' SIGWINCH
+trap -- 'echo WINCH!' WINCH
trap -- 'echo Exiting' EXIT
-trap -- 'echo WINCH!' SIGWINCH
+trap -- 'echo WINCH!' WINCH
Done
Exiting
got signal
-trap -- 'echo got signal' SIGUSR1
+trap -- 'echo got signal' USR1
sent 1 signal
got signal
wait interrupted
-trap -- 'echo got signal' SIGUSR1
+trap -- 'echo got signal' USR1
sent 2 signal
got signal
wait interrupted
-trap -- 'echo got signal' SIGUSR1
+trap -- 'echo got signal' USR1
sent 3 signal
got signal
wait interrupted
-trap -- 'echo got signal' SIGUSR1
+trap -- 'echo got signal' USR1
sent 4 signal
got signal
wait interrupted
-trap -- 'echo got signal' SIGUSR1
+trap -- 'echo got signal' USR1
sent 5 signal
sleep completed
if (G.traps[i]) {
printf("trap -- ");
print_escaped(G.traps[i]);
- /* bash compat: it says SIGxxx, not just xxx */
- printf(" %s%s\n", i == 0 ? "" : "SIG", get_signame(i));
+ /* note: bash adds "SIG", but only if invoked
+ * as "bash". If called as "sh", or if set -o posix,
+ * then it prints short signal names.
+ * We are printing short names: */
+ printf(" %s\n", get_signame(i));
}
}
/*fflush(stdout); - done after each builtin anyway */
trap -- 'echo Exiting' EXIT
-trap -- 'echo WINCH!' SIGWINCH
+trap -- 'echo WINCH!' WINCH
trap -- 'echo Exiting' EXIT
-trap -- 'echo WINCH!' SIGWINCH
+trap -- 'echo WINCH!' WINCH
trap -- 'echo Exiting' EXIT
-trap -- 'echo WINCH!' SIGWINCH
+trap -- 'echo WINCH!' WINCH
Done
Exiting
___
___
trap -- 'a' EXIT
-trap -- 'a' SIGINT
-trap -- 'a' SIGUSR1
-trap -- 'a' SIGUSR2
+trap -- 'a' INT
+trap -- 'a' USR1
+trap -- 'a' USR2
___
___
-trap -- 'a' SIGUSR1
-trap -- 'a' SIGUSR2
+trap -- 'a' USR1
+trap -- 'a' USR2
___
___
-trap -- 'a' SIGUSR2
+trap -- 'a' USR2