summaryrefslogtreecommitdiff
path: root/bin/ksh/siglist.sh
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1996-08-14 06:19:13 +0000
committerJason Downs <downsj@cvs.openbsd.org>1996-08-14 06:19:13 +0000
commit3039b959c7de1e35fe4ec27ae02f1c8fe8d4d4ac (patch)
tree09c6b5a4f13282e07afe153445fcfaa0d10651f4 /bin/ksh/siglist.sh
parent596c2317eee31ab9606c6b88085644407d4d2f0f (diff)
Import pdksh 5.2.7.
Diffstat (limited to 'bin/ksh/siglist.sh')
-rw-r--r--bin/ksh/siglist.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/ksh/siglist.sh b/bin/ksh/siglist.sh
new file mode 100644
index 00000000000..420aaf6dd05
--- /dev/null
+++ b/bin/ksh/siglist.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+# $OpenBSD: siglist.sh,v 1.1 1996/08/14 06:19:11 downsj Exp $
+
+#
+# Script to generate a sorted, complete list of signals, suitable
+# for inclusion in trap.c as array initializer.
+#
+
+set -e
+
+in=tmpi$$.c
+out=tmpo$$.c
+ecode=1
+trapsigs='0 1 2 13 15'
+trap 'rm -f $in $out; trap 0; exit $ecode' $trapsigs
+
+CPP="${1-cc -E}"
+
+# The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap
+(trap $trapsigs;
+ echo '#include "sh.h"';
+ echo ' { QwErTy SIGNALS , "DUMMY" , "hook for number of signals" },';
+ sed -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\
+ { QwErTy SIG\1 , "\1", "\2" },\
+#endif/') > $in
+$CPP $in > $out
+sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort +2n +0n |
+ sed 's/^[0-9]* //' |
+ awk 'BEGIN { last=0; nsigs=0; }
+ {
+ n = $2;
+ if (n > 0 && n != last) {
+ while (++last < n) {
+ printf "\t{ %d , (char *) 0, `Signal %d` } ,\n", last, last;
+ }
+ print;
+ }
+ }' |
+ tr '`' '"' | grep -v '"DUMMY"'
+ecode=0