summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2009-09-27 02:05:45 +0200
committerDenys Vlasenko2009-09-27 02:05:45 +0200
commite74aaf93854b9453b9949954aec77710b257d8b6 (patch)
tree0be4c4457b9567427706871bfb62fafa296eca19
parent6c750f15180ba51ef37c6cfa381b52e6b05d55aa (diff)
downloadbusybox-e74aaf93854b9453b9949954aec77710b257d8b6.zip
busybox-e74aaf93854b9453b9949954aec77710b257d8b6.tar.gz
ash,hush: make trap output short signal names, without SIG prefix
function old new delta evalvar 1373 1371 -2 builtin_trap 457 441 -16 trapcmd 260 236 -24 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c9
-rw-r--r--shell/ash_test/ash-signals/savetrap.right6
-rw-r--r--shell/ash_test/ash-signals/signal1.right10
-rw-r--r--shell/hush.c7
-rw-r--r--shell/hush_test/hush-trap/savetrap.right6
-rw-r--r--shell/hush_test/hush-trap/usage.right12
6 files changed, 28 insertions, 22 deletions
diff --git a/shell/ash.c b/shell/ash.c
index c909cae..d7355ce 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -12267,13 +12267,16 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
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); */
}
}
diff --git a/shell/ash_test/ash-signals/savetrap.right b/shell/ash_test/ash-signals/savetrap.right
index 9cfd7a5..a59225b 100644
--- a/shell/ash_test/ash-signals/savetrap.right
+++ b/shell/ash_test/ash-signals/savetrap.right
@@ -1,8 +1,8 @@
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
diff --git a/shell/ash_test/ash-signals/signal1.right b/shell/ash_test/ash-signals/signal1.right
index beb0a98..cf403ac 100644
--- a/shell/ash_test/ash-signals/signal1.right
+++ b/shell/ash_test/ash-signals/signal1.right
@@ -1,20 +1,20 @@
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
diff --git a/shell/hush.c b/shell/hush.c
index d75b0da..b515eab 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7111,8 +7111,11 @@ static int FAST_FUNC builtin_trap(char **argv)
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 */
diff --git a/shell/hush_test/hush-trap/savetrap.right b/shell/hush_test/hush-trap/savetrap.right
index 9cfd7a5..a59225b 100644
--- a/shell/hush_test/hush-trap/savetrap.right
+++ b/shell/hush_test/hush-trap/savetrap.right
@@ -1,8 +1,8 @@
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
diff --git a/shell/hush_test/hush-trap/usage.right b/shell/hush_test/hush-trap/usage.right
index 5b90222..c0dbd6c 100644
--- a/shell/hush_test/hush-trap/usage.right
+++ b/shell/hush_test/hush-trap/usage.right
@@ -2,13 +2,13 @@ ___
___
___
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