Get csh working, add tests
authorNick Downing <downing.nick@gmail.com>
Tue, 31 Jan 2017 04:34:28 +0000 (15:34 +1100)
committerNick Downing <downing.nick@gmail.com>
Tue, 31 Jan 2017 04:34:28 +0000 (15:34 +1100)
194 files changed:
.gitignore
bin/as/tests/as.ok [moved from bin/as/test/as.ok with 100% similarity]
bin/as/tests/ascode.o.ok [moved from bin/as/test/ascode.o.ok with 100% similarity]
bin/as/tests/ascode.s [moved from bin/as/test/ascode.s with 100% similarity]
bin/as/tests/asexpr.o.ok [moved from bin/as/test/asexpr.o.ok with 100% similarity]
bin/as/tests/asexpr.s [moved from bin/as/test/asexpr.s with 100% similarity]
bin/as/tests/asio.o.ok [moved from bin/as/test/asio.o.ok with 100% similarity]
bin/as/tests/asio.s [moved from bin/as/test/asio.s with 100% similarity]
bin/as/tests/asjxxx.o.ok [moved from bin/as/test/asjxxx.o.ok with 100% similarity]
bin/as/tests/asjxxx.s [moved from bin/as/test/asjxxx.s with 100% similarity]
bin/as/tests/asmain.o.ok [moved from bin/as/test/asmain.o.ok with 100% similarity]
bin/as/tests/asmain.s [moved from bin/as/test/asmain.s with 100% similarity]
bin/as/tests/asparse.o.ok [moved from bin/as/test/asparse.o.ok with 100% similarity]
bin/as/tests/asparse.s [moved from bin/as/test/asparse.s with 100% similarity]
bin/as/tests/aspseudo.o.ok [moved from bin/as/test/aspseudo.o.ok with 100% similarity]
bin/as/tests/aspseudo.s [moved from bin/as/test/aspseudo.s with 100% similarity]
bin/as/tests/asscan1.o.ok [moved from bin/as/test/asscan1.o.ok with 100% similarity]
bin/as/tests/asscan1.s [moved from bin/as/test/asscan1.s with 100% similarity]
bin/as/tests/asscan2.o.ok [moved from bin/as/test/asscan2.o.ok with 100% similarity]
bin/as/tests/asscan2.s [moved from bin/as/test/asscan2.s with 100% similarity]
bin/as/tests/asscan3.o.ok [moved from bin/as/test/asscan3.o.ok with 100% similarity]
bin/as/tests/asscan3.s [moved from bin/as/test/asscan3.s with 100% similarity]
bin/as/tests/asscan4.o.ok [moved from bin/as/test/asscan4.o.ok with 100% similarity]
bin/as/tests/asscan4.s [moved from bin/as/test/asscan4.s with 100% similarity]
bin/as/tests/assizetab.o.ok [moved from bin/as/test/assizetab.o.ok with 100% similarity]
bin/as/tests/assizetab.s [moved from bin/as/test/assizetab.s with 100% similarity]
bin/as/tests/assyms.o.ok [moved from bin/as/test/assyms.o.ok with 100% similarity]
bin/as/tests/assyms.s [moved from bin/as/test/assyms.s with 100% similarity]
bin/as/tests/bignum1.o.ok [moved from bin/as/test/bignum1.o.ok with 100% similarity]
bin/as/tests/bignum1.s [moved from bin/as/test/bignum1.s with 100% similarity]
bin/as/tests/bignum2.o.ok [moved from bin/as/test/bignum2.o.ok with 100% similarity]
bin/as/tests/bignum2.s [moved from bin/as/test/bignum2.s with 100% similarity]
bin/as/tests/crt0.o.ok [moved from bin/as/test/crt0.o.ok with 100% similarity]
bin/as/tests/floattab.o.ok [moved from bin/as/test/floattab.o.ok with 100% similarity]
bin/as/tests/floattab.s [moved from bin/as/test/floattab.s with 100% similarity]
bin/as/tests/libc.a.ok [moved from bin/as/test/libc.a.ok with 100% similarity]
bin/as/tests/n.sh [moved from bin/as/test/n.sh with 100% similarity]
bin/as/tests/natof.o.ok [moved from bin/as/test/natof.o.ok with 100% similarity]
bin/as/tests/natof.s [moved from bin/as/test/natof.s with 100% similarity]
bin/awk/tests/Awk - A Tutorial and Introduction - by Bruce Barnett.pdf [new file with mode: 0644]
bin/awk/tests/Column1.sh [new file with mode: 0755]
bin/awk/tests/Column2.sh [new file with mode: 0755]
bin/awk/tests/Column3.sh [new file with mode: 0755]
bin/awk/tests/Column4.sh [new file with mode: 0755]
bin/awk/tests/Column5.sh [new file with mode: 0755]
bin/awk/tests/add_cr.awk [new file with mode: 0755]
bin/awk/tests/average.awk [new file with mode: 0755]
bin/awk/tests/awk_ask_for_square.awk [new file with mode: 0755]
bin/awk/tests/awk_example1.awk [new file with mode: 0755]
bin/awk/tests/awk_example1.csh [new file with mode: 0755]
bin/awk/tests/awk_example1.sh [new file with mode: 0755]
bin/awk/tests/awk_example10.awk [new file with mode: 0755]
bin/awk/tests/awk_example11.awk [new file with mode: 0755]
bin/awk/tests/awk_example12.awk [new file with mode: 0755]
bin/awk/tests/awk_example13.awk [new file with mode: 0755]
bin/awk/tests/awk_example14.sh [new file with mode: 0755]
bin/awk/tests/awk_example15.awk [new file with mode: 0755]
bin/awk/tests/awk_example16.awk [new file with mode: 0755]
bin/awk/tests/awk_example17.awk [new file with mode: 0755]
bin/awk/tests/awk_example17.gawk [new file with mode: 0755]
bin/awk/tests/awk_example18.nawk [new file with mode: 0755]
bin/awk/tests/awk_example2.awk [new file with mode: 0755]
bin/awk/tests/awk_example2.csh [new file with mode: 0755]
bin/awk/tests/awk_example2.sh [new file with mode: 0755]
bin/awk/tests/awk_example3.awk [new file with mode: 0755]
bin/awk/tests/awk_example4.awk [new file with mode: 0755]
bin/awk/tests/awk_example4a.awk [new file with mode: 0755]
bin/awk/tests/awk_example5.awk [new file with mode: 0755]
bin/awk/tests/awk_example6.awk [new file with mode: 0755]
bin/awk/tests/awk_example6a.awk [new file with mode: 0755]
bin/awk/tests/awk_example7.awk [new file with mode: 0755]
bin/awk/tests/awk_example8.awk [new file with mode: 0755]
bin/awk/tests/awk_example9.awk [new file with mode: 0755]
bin/awk/tests/awk_nopasswd.awk [new file with mode: 0755]
bin/awk/tests/awk_print_squares.awk [new file with mode: 0755]
bin/awk/tests/center.awk [new file with mode: 0755]
bin/awk/tests/count_users.awk [new file with mode: 0755]
bin/awk/tests/count_users0.awk [new file with mode: 0755]
bin/awk/tests/count_users1.awk [new file with mode: 0755]
bin/awk/tests/count_users2.awk [new file with mode: 0755]
bin/awk/tests/count_users3.awk [new file with mode: 0755]
bin/awk/tests/count_users_new.awk [new file with mode: 0755]
bin/awk/tests/date.gawk [new file with mode: 0755]
bin/awk/tests/delete_passwd.awk [new file with mode: 0755]
bin/awk/tests/email.awk [new file with mode: 0755]
bin/awk/tests/include.nawk [new file with mode: 0755]
bin/awk/tests/lotto.awk [new file with mode: 0755]
bin/awk/tests/one_week_later.gawk [new file with mode: 0755]
bin/awk/tests/oneword_per_line.awk [new file with mode: 0755]
bin/awk/tests/owner_group.awk [new file with mode: 0755]
bin/awk/tests/print_last_field.awk [new file with mode: 0755]
bin/awk/tests/random.awk [new file with mode: 0755]
bin/awk/tests/trigonometry.awk [new file with mode: 0755]
bin/awk/tests/upper_to_lower.awk [new file with mode: 0755]
bin/awk/tests/upper_to_lower.gawk [new file with mode: 0755]
bin/csh/Makefile
bin/csh/tests/Aliases4.csh [new file with mode: 0755]
bin/csh/tests/AliasesC.csh [new file with mode: 0755]
bin/csh/tests/AnalyzePaths.csh [new file with mode: 0755]
bin/csh/tests/Cheer.csh [new file with mode: 0755]
bin/csh/tests/CreateCacheDir.sh [new file with mode: 0755]
bin/csh/tests/Csh - the C Shell.pdf [new file with mode: 0644]
bin/csh/tests/Csh1.csh [new file with mode: 0755]
bin/csh/tests/Csh2.csh [new file with mode: 0755]
bin/csh/tests/CshAwk.csh [new file with mode: 0755]
bin/csh/tests/Cshrc1 [new file with mode: 0644]
bin/csh/tests/Dir_to_System.sh [new file with mode: 0755]
bin/csh/tests/Foreach1.csh [new file with mode: 0755]
bin/csh/tests/Foreach2.csh [new file with mode: 0755]
bin/csh/tests/GetDate.csh [new file with mode: 0755]
bin/csh/tests/GetPaths.csh [new file with mode: 0755]
bin/csh/tests/Header.csh [new file with mode: 0755]
bin/csh/tests/OpenWin.csh [new file with mode: 0755]
bin/csh/tests/Path.default [new file with mode: 0644]
bin/csh/tests/Path.sunos [new file with mode: 0644]
bin/csh/tests/Path1.csh [new file with mode: 0755]
bin/csh/tests/ResolveDir.sh [new file with mode: 0755]
bin/csh/tests/Scripts/analyze_paths.nawk [new file with mode: 0644]
bin/csh/tests/Which.csh [new file with mode: 0755]
bin/csh/tests/Which.sh [new file with mode: 0755]
bin/csh/tests/WordCount.csh [new file with mode: 0755]
bin/csh/tests/Zappath.sh [new file with mode: 0755]
bin/csh/tests/myexit.csh [new file with mode: 0755]
bin/csh/tests/prog.csh [new file with mode: 0755]
bin/sed/tests/CapVowel.sed [new file with mode: 0755]
bin/sed/tests/Sed - An Introduction and Tutorial.pdf [new file with mode: 0644]
bin/sed/tests/convert2uc.sh [new file with mode: 0755]
bin/sed/tests/convert2uc1.sh [new file with mode: 0755]
bin/sed/tests/convert2uc2.sh [new file with mode: 0755]
bin/sed/tests/delete_nested_parens.sh [new file with mode: 0755]
bin/sed/tests/grep3.sh [new file with mode: 0755]
bin/sed/tests/grep3a.sh [new file with mode: 0755]
bin/sed/tests/grep3c.sh [new file with mode: 0755]
bin/sed/tests/grep4.sh [new file with mode: 0755]
bin/sed/tests/grep4a.sh [new file with mode: 0755]
bin/sed/tests/grep_paragraph.sh [new file with mode: 0755]
bin/sed/tests/grep_previous.sh [new file with mode: 0755]
bin/sed/tests/sed_add_comments.sh [new file with mode: 0755]
bin/sed/tests/sed_add_line_after_word.sh [new file with mode: 0755]
bin/sed/tests/sed_add_line_after_word1.sh [new file with mode: 0755]
bin/sed/tests/sed_add_line_before_word.sh [new file with mode: 0755]
bin/sed/tests/sed_addslash_before_blank.csh [new file with mode: 0755]
bin/sed/tests/sed_addslash_before_blank.sh [new file with mode: 0755]
bin/sed/tests/sed_bad_example.sh [new file with mode: 0755]
bin/sed/tests/sed_begin_end.sh [new file with mode: 0755]
bin/sed/tests/sed_begin_end1.sh [new file with mode: 0755]
bin/sed/tests/sed_begin_end2.sh [new file with mode: 0755]
bin/sed/tests/sed_change_line.sh [new file with mode: 0755]
bin/sed/tests/sed_delete_between_two_words.sh [new file with mode: 0755]
bin/sed/tests/sed_delete_line_after_word.sh [new file with mode: 0755]
bin/sed/tests/sed_hereis.sed [new file with mode: 0755]
bin/sed/tests/sed_include.sh [new file with mode: 0755]
bin/sed/tests/sed_include1.sh [new file with mode: 0755]
bin/sed/tests/sed_include2.sh [new file with mode: 0755]
bin/sed/tests/sed_insert_append_change.sh [new file with mode: 0755]
bin/sed/tests/sed_merge_two_lines.sh [new file with mode: 0755]
bin/sed/tests/sed_print_line_after_word.sh [new file with mode: 0755]
bin/sed/tests/sed_split.sh [new file with mode: 0755]
bin/sed/tests/sed_split_merge.sh [new file with mode: 0755]
bin/sed/tests/sed_tail.sh [new file with mode: 0755]
bin/sed/tests/sed_with_regular_expressions1.sh [new file with mode: 0755]
bin/sed/tests/sedgrep.sed [new file with mode: 0755]
bin/sh/tests/0.sh [new file with mode: 0755]
bin/sh/tests/Bourne Shell Tutorial.pdf [new file with mode: 0644]
bin/sh/tests/CountLines0.sh [new file with mode: 0755]
bin/sh/tests/EchoArgs.sh [new file with mode: 0755]
bin/sh/tests/ShCmdArgs.sh [new file with mode: 0755]
bin/sh/tests/ShCmdArgs3.sh [new file with mode: 0755]
bin/sh/tests/ShCmdArgs4.sh [new file with mode: 0755]
bin/sh/tests/ShCmdChk1.sh [new file with mode: 0755]
bin/sh/tests/ShCmdChk2.sh [new file with mode: 0755]
bin/sh/tests/ShCmdChk3.sh [new file with mode: 0755]
bin/sh/tests/ShCmdChk4.sh [new file with mode: 0755]
bin/sh/tests/TestEchoArgs.sh [new file with mode: 0755]
bin/sh/tests/diskwarn.sh [new file with mode: 0755]
bin/sh/tests/moveto.sh [new file with mode: 0755]
bin/sh/tests/rename.sh [new file with mode: 0755]
bin/sh/tests/rename0.sh [new file with mode: 0755]
bin/tests/Grep.pdf [new file with mode: 0644]
bin/tests/Tar.pdf [new file with mode: 0644]
bin/tests/igrep.sh [new file with mode: 0644]
lib/libc/linux/sys/Makefile
lib/libc/linux/sys/getrusage.c
lib/libc/linux/sys/linux.c
lib/libc/linux/sys/linux.h
lib/libc/linux/sys/sigblock.c [new file with mode: 0644]
lib/libc/linux/sys/sigpause.c [new file with mode: 0644]
lib/libc/linux/sys/sigsetmask.c [new file with mode: 0644]
lib/libc/linux/sys/sigvec.c
lib/libc/linux/sys/wait.c
lib/libc/linux/sys/wait3.c [new file with mode: 0644]
lib/libc/sys/sigpause.c
sys/h/signal.h
usr.bin/find/tests/Find.pdf [new file with mode: 0644]

index 2dc9feb..bda78ba 100644 (file)
@@ -54,6 +54,7 @@ bin/rm
 bin/rmail
 bin/rmdir
 bin/sed/sed
+bin/sh/sh
 bin/size
 bin/strip
 bin/stty
similarity index 100%
rename from bin/as/test/as.ok
rename to bin/as/tests/as.ok
similarity index 100%
rename from bin/as/test/ascode.s
rename to bin/as/tests/ascode.s
similarity index 100%
rename from bin/as/test/asexpr.s
rename to bin/as/tests/asexpr.s
similarity index 100%
rename from bin/as/test/asio.o.ok
rename to bin/as/tests/asio.o.ok
similarity index 100%
rename from bin/as/test/asio.s
rename to bin/as/tests/asio.s
similarity index 100%
rename from bin/as/test/asjxxx.s
rename to bin/as/tests/asjxxx.s
similarity index 100%
rename from bin/as/test/asmain.s
rename to bin/as/tests/asmain.s
similarity index 100%
rename from bin/as/test/asparse.s
rename to bin/as/tests/asparse.s
similarity index 100%
rename from bin/as/test/asscan1.s
rename to bin/as/tests/asscan1.s
similarity index 100%
rename from bin/as/test/asscan2.s
rename to bin/as/tests/asscan2.s
similarity index 100%
rename from bin/as/test/asscan3.s
rename to bin/as/tests/asscan3.s
similarity index 100%
rename from bin/as/test/asscan4.s
rename to bin/as/tests/asscan4.s
similarity index 100%
rename from bin/as/test/assyms.s
rename to bin/as/tests/assyms.s
similarity index 100%
rename from bin/as/test/bignum1.s
rename to bin/as/tests/bignum1.s
similarity index 100%
rename from bin/as/test/bignum2.s
rename to bin/as/tests/bignum2.s
similarity index 100%
rename from bin/as/test/crt0.o.ok
rename to bin/as/tests/crt0.o.ok
similarity index 100%
rename from bin/as/test/libc.a.ok
rename to bin/as/tests/libc.a.ok
similarity index 100%
rename from bin/as/test/n.sh
rename to bin/as/tests/n.sh
similarity index 100%
rename from bin/as/test/natof.s
rename to bin/as/tests/natof.s
diff --git a/bin/awk/tests/Awk - A Tutorial and Introduction - by Bruce Barnett.pdf b/bin/awk/tests/Awk - A Tutorial and Introduction - by Bruce Barnett.pdf
new file mode 100644 (file)
index 0000000..63c29cc
Binary files /dev/null and b/bin/awk/tests/Awk - A Tutorial and Introduction - by Bruce Barnett.pdf differ
diff --git a/bin/awk/tests/Column1.sh b/bin/awk/tests/Column1.sh
new file mode 100755 (executable)
index 0000000..64a611b
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+#NOTE - this script does not work!
+column=$1
+awk '{print $$column}'
diff --git a/bin/awk/tests/Column2.sh b/bin/awk/tests/Column2.sh
new file mode 100755 (executable)
index 0000000..d9fc7f7
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+column=$1
+awk '{print $'$column'}'
diff --git a/bin/awk/tests/Column3.sh b/bin/awk/tests/Column3.sh
new file mode 100755 (executable)
index 0000000..945dcbc
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+column=${1:-1}
+awk '{print $'$column'}'
diff --git a/bin/awk/tests/Column4.sh b/bin/awk/tests/Column4.sh
new file mode 100755 (executable)
index 0000000..c16004b
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+awk '{print $'${1:-1}'}'
diff --git a/bin/awk/tests/Column5.sh b/bin/awk/tests/Column5.sh
new file mode 100755 (executable)
index 0000000..9f8fcc9
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+awk '{print $c}' c=${1:-1}
diff --git a/bin/awk/tests/add_cr.awk b/bin/awk/tests/add_cr.awk
new file mode 100755 (executable)
index 0000000..d03414d
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/awk -f
+# this filter adds a carriage return to all lines
+# before the newline character
+BEGIN {        
+       ORS="\r\n"
+}
+{ print }
diff --git a/bin/awk/tests/average.awk b/bin/awk/tests/average.awk
new file mode 100755 (executable)
index 0000000..1ad4b00
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/awk -f
+BEGIN {
+# How many lines
+    lines=0;
+    total=0;
+}
+{
+# this code is executed once for each line
+# increase the number of files
+    lines++;
+# increase the total size, which is field #1
+    total+=$1;
+}
+END {
+# end, now output the total
+    print lines " lines read";
+    print "total is ", total;
+    if (lines > 0 ) {
+       print "average is ", total/lines;
+    } else {
+       print "average is 0";
+    }
+}
diff --git a/bin/awk/tests/awk_ask_for_square.awk b/bin/awk/tests/awk_ask_for_square.awk
new file mode 100755 (executable)
index 0000000..f1698af
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/awk -f
+BEGIN {
+    print "type a number";
+}
+{
+    print "The square of ", $1, " is ", $1*$1;
+    print "type another number";
+}
+END {
+    print "Done"
+}
diff --git a/bin/awk/tests/awk_example1.awk b/bin/awk/tests/awk_example1.awk
new file mode 100755 (executable)
index 0000000..f11aeb5
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/awk -f
+# Linux users have to change $8 to $9
+BEGIN  { print "File\tOwner" }
+               { print $8, "\t", $3}
+END    { print " - DONE -" }
diff --git a/bin/awk/tests/awk_example1.csh b/bin/awk/tests/awk_example1.csh
new file mode 100755 (executable)
index 0000000..eeafb0e
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/csh -f
+# Linux users have to change $8 to $9
+awk '\
+BEGIN  { print "File\tOwner" } \
+               { print $8, "\t", $3}   \
+END    { print " - DONE -" } \
+'
diff --git a/bin/awk/tests/awk_example1.sh b/bin/awk/tests/awk_example1.sh
new file mode 100755 (executable)
index 0000000..c9aad0e
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Linux users have to change $8 to $9
+awk '
+BEGIN  { print "File\tOwner" } 
+               { print $8, "\t", $3}   
+END    { print " - DONE -" } 
+'
diff --git a/bin/awk/tests/awk_example10.awk b/bin/awk/tests/awk_example10.awk
new file mode 100755 (executable)
index 0000000..777e5c8
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/awk -f
+BEGIN {
+       printf("%10s %6s\n", "String", "Number");
+}
+{
+       printf("%10s %6d\n", $1, $2);
+}
diff --git a/bin/awk/tests/awk_example11.awk b/bin/awk/tests/awk_example11.awk
new file mode 100755 (executable)
index 0000000..1d6c67e
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/awk -f
+BEGIN {
+       format1 ="%10s %6s\n";
+       format2 ="%10s %6d\n";
+       printf(format1, "String", "Number");
+}
+{
+       printf(format2, $1, $2);
+}
diff --git a/bin/awk/tests/awk_example12.awk b/bin/awk/tests/awk_example12.awk
new file mode 100755 (executable)
index 0000000..7d5b01a
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/awk -f
+END {
+    for (i=0;i<30;i++) {
+       printf("i=%d\n", i) > "/tmp/a" i;
+    }
+}
diff --git a/bin/awk/tests/awk_example13.awk b/bin/awk/tests/awk_example13.awk
new file mode 100755 (executable)
index 0000000..b6871b3
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/awk -f
+# demonstrate use of exp(), log() and sqrt in AWK
+# e.g. what is the difference between using logarithms and regular arithmetic
+# note - exp and log are natural log functions - not base 10
+#
+BEGIN {
+# what is the about of error that will be reported?
+       ERROR=0.000000000001;
+# loop a long while
+       for (i=1;i<=2147483647;i++) {
+# find log of i
+               logi=log(i);
+# what is square root of i? 
+# divide the log by 2
+               logsquareroot=logi/2;
+# convert log of i back
+               squareroot=exp(logsquareroot);
+# find the difference between the logarithmic calculation
+# and the built in calculation
+               diff=sqrt(i)-squareroot;
+# make difference positive 
+               if (diff < 0) {
+                       diff*=-1;
+               }
+               if (diff > ERROR) {
+                       printf("%10d, squareroot: %16.8f, error: %16.14f\n", \
+                               i, squareroot, diff);
+               }
+       }
+       exit;
+}
diff --git a/bin/awk/tests/awk_example14.sh b/bin/awk/tests/awk_example14.sh
new file mode 100755 (executable)
index 0000000..8c7d8db
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/awk -f
+BEGIN {
+# this script breaks up the sentence into words, using 
+# a space as the character separating the words
+    string="This is a string, is it not?";
+    search=" ";
+    n=split(string,array,search);
+    for (i=1;i<=n;i++) {
+        printf("Word[%d]=%s\n",i,array[i]);
+    }
+    exit;
+}
diff --git a/bin/awk/tests/awk_example15.awk b/bin/awk/tests/awk_example15.awk
new file mode 100755 (executable)
index 0000000..0ac6010
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/nawk -f
+BEGIN {
+    string = "Another sample of an example sentence";
+    pattern="[Aa]n";
+    if (gsub(pattern,"AN",string)) {
+        printf("Substitution occurred: %s\n", string);
+    }
+
+    exit;
+}
diff --git a/bin/awk/tests/awk_example16.awk b/bin/awk/tests/awk_example16.awk
new file mode 100755 (executable)
index 0000000..ac53588
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/nawk -f
+# demonstrate the match function
+
+BEGIN {
+    regex="[a-zA-Z0-9]+";
+}
+{
+    if (match($0,regex)) {
+#           RSTART is where the pattern starts
+#           RLENGTH is the length of the pattern
+            before = substr($0,1,RSTART-1);
+            pattern = substr($0,RSTART,RLENGTH);
+            after = substr($0,RSTART+RLENGTH);
+            printf("%s<%s>%s\n", before, pattern, after);
+    }
+}
diff --git a/bin/awk/tests/awk_example17.awk b/bin/awk/tests/awk_example17.awk
new file mode 100755 (executable)
index 0000000..433bf0b
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/awk -f
+# look for a \ as the last character.
+# if found, read the next line and append
+{
+    line = $0;
+    while (substr(line,length(line),1) == "\\") {
+# chop off the last character
+        line = substr(line,1,length(line)-1);
+        i=getline;
+        if (i > 0) {
+            line = line $0;
+        } else {
+            printf("missing continuation on line %d\n", NR);
+        }
+    }
+    print line;
+}
diff --git a/bin/awk/tests/awk_example17.gawk b/bin/awk/tests/awk_example17.gawk
new file mode 100755 (executable)
index 0000000..32ec92c
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/local/bin/gawk -f
+# how long does it take to do a few loops?
+BEGIN {
+    LOOPS=100;
+# do the test twice
+    start=systime();
+    for (i=0;i<LOOPS;i++) {
+    }
+    end = systime();
+# calculate how long it takes to do a dummy test
+    do_nothing = end-start;
+# now do the test again with the *IMPORTANT* code inside
+    start=systime();
+    for (i=0;i<LOOPS;i++) {
+# How long does this take?
+        while ("date" | getline) {
+            date = $0;
+        }
+        close("date");
+    }
+    end = systime();
+    newtime = (end - start) - do_nothing;
+
+    if (newtime <= 0) {
+        printf("%d loops were not enough to test, increase it\n", 
+            LOOPS);
+        exit;
+    } else {
+        printf("%d loops took %6.4f seconds to execute\n", 
+            LOOPS, newtime);
+        printf("That's %10.8f seconds per loop\n", 
+            (newtime)/LOOPS);
+# since the clock has an accuracy of +/- one second, what is the error
+        printf("accuracy of this measurement = %6.2f%%\n",
+            (1/(newtime))*100);
+    }
+    exit;
+}
diff --git a/bin/awk/tests/awk_example18.nawk b/bin/awk/tests/awk_example18.nawk
new file mode 100755 (executable)
index 0000000..9d80bee
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/nawk -f
+{
+    if (NF != 4) {
+        error("Expected 4 fields");
+    } else {
+        print;
+    }
+}
+function error ( message ) {
+    if (FILENAME != "-") {
+        printf("%s: ", FILENAME) > "/dev/tty";
+    }
+    printf("line # %d, %s, line: %s\n", NR, message, $0) >> "/dev/tty";
+}
diff --git a/bin/awk/tests/awk_example2.awk b/bin/awk/tests/awk_example2.awk
new file mode 100755 (executable)
index 0000000..b7dc6be
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/awk -f
+# Linux users have to change $8 to $9
+BEGIN  { print "File\tOwner" }
+               { print $8, "\t", \
+               $3} 
+END    { print " - DONE -" }
diff --git a/bin/awk/tests/awk_example2.csh b/bin/awk/tests/awk_example2.csh
new file mode 100755 (executable)
index 0000000..b0b81a3
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/csh -f
+# Linux users have to change $8 to $9
+awk '\
+BEGIN  { print "File\tOwner" }\
+               { print $8, "\t", \\
+               $3}\
+END            { print "done"}\
+'
diff --git a/bin/awk/tests/awk_example2.sh b/bin/awk/tests/awk_example2.sh
new file mode 100755 (executable)
index 0000000..abcd73c
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+# Linux users have to change $8 to $9
+awk '
+BEGIN  { print "File\tOwner" }
+               { print $8, "\t", \
+               $3}
+END            { print "done"} 
+'
diff --git a/bin/awk/tests/awk_example3.awk b/bin/awk/tests/awk_example3.awk
new file mode 100755 (executable)
index 0000000..930503c
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/awk -f
+{
+       if ($1 == "#START") {
+               FS=":";
+       } else if ($1 == "#STOP") {
+               FS=" ";
+       } else {
+               #print the Roman number in column 3
+               print $3
+       }
+}
diff --git a/bin/awk/tests/awk_example4.awk b/bin/awk/tests/awk_example4.awk
new file mode 100755 (executable)
index 0000000..efd71f5
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/awk -f
+{
+       if ( $0 ~ /:/ ) {
+               FS=":";
+       } else {
+               FS=" ";
+       }
+       #print the third field, whatever format
+       print $3
+}
diff --git a/bin/awk/tests/awk_example4a.awk b/bin/awk/tests/awk_example4a.awk
new file mode 100755 (executable)
index 0000000..74df24c
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/awk -f
+{
+       if ( $0 ~ /:/ ) {
+               FS=":";
+               $0=$0
+       } else {
+               FS=" ";
+               $0=$0
+       }
+       #print the third field, whatever format
+       print $3
+}
diff --git a/bin/awk/tests/awk_example5.awk b/bin/awk/tests/awk_example5.awk
new file mode 100755 (executable)
index 0000000..ff0cda0
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/awk -f
+{ if (NR > 100) {
+       print NR, $0;
+}
diff --git a/bin/awk/tests/awk_example6.awk b/bin/awk/tests/awk_example6.awk
new file mode 100755 (executable)
index 0000000..06950b4
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/awk -f
+BEGIN {
+# change the record separator from newline to nothing  
+       RS=""
+# change the field separator from whitespace to newline
+       FS="\n"
+}
+{
+# print the second and third line of the file
+       print $2, $3;
+}
diff --git a/bin/awk/tests/awk_example6a.awk b/bin/awk/tests/awk_example6a.awk
new file mode 100755 (executable)
index 0000000..20b2b93
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/awk -f
+# reports which file is being read
+BEGIN {
+       f="";
+}
+{      if (f != FILENAME) {
+               print "reading", FILENAME;
+               f=FILENAME;
+       }
+       print;
+}
diff --git a/bin/awk/tests/awk_example7.awk b/bin/awk/tests/awk_example7.awk
new file mode 100755 (executable)
index 0000000..56f1e35
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/awk -f
+{ 
+    if (NF == 6) {
+        # do the right thing
+    } else {
+        if (FILENAME == "-" ) {
+            print "SYNTAX ERROR, Wrong number of fields,", \
+            "in STDIN, line #:", NR,  "line: ", $0;
+        } else {
+            print "SYNTAX ERROR, Wrong number of fields,", \
+            "Filename: ", FILENAME, "line # ", NR,"line: ", $0;
+        }
+    }
+}
diff --git a/bin/awk/tests/awk_example8.awk b/bin/awk/tests/awk_example8.awk
new file mode 100755 (executable)
index 0000000..294df09
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/awk -f
+# bad example of AWK programming
+# this counts how many files each user owns.
+BEGIN {
+       number_of_users=0;
+}
+{
+# must make sure you only examine lines with 8 or more fields
+       if (NF>7) {
+               user=0;
+# look for the user in our list of users
+               for (i=1; i<=number_of_users; i++) {
+#              is the user known?
+                       if (username[i] == $3) {
+# found it - remember where the user is
+                               user=i;
+                       }
+               }
+               if (user == 0) {
+# found a new user
+                       username[++number_of_users]=$3;
+                       user=number_of_users;
+               }
+# increase number of counts
+               count[user]++;
+       }
+}
+END {
+       for (i=1; i<=number_of_users; i++) {
+               print count[i], username[i]
+       }
+}
diff --git a/bin/awk/tests/awk_example9.awk b/bin/awk/tests/awk_example9.awk
new file mode 100755 (executable)
index 0000000..704bec8
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/awk -f
+BEGIN {
+       printf("String     Number\n");
+}
+{
+       printf("%10s %6d\n", $1, $2);
+}
diff --git a/bin/awk/tests/awk_nopasswd.awk b/bin/awk/tests/awk_nopasswd.awk
new file mode 100755 (executable)
index 0000000..3329a8c
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/awk -f
+BEGIN {
+       FS=":";
+}
+{
+       if ( $2 == "" ) {
+               print $1 ": no password!";
+       }
+}
diff --git a/bin/awk/tests/awk_print_squares.awk b/bin/awk/tests/awk_print_squares.awk
new file mode 100755 (executable)
index 0000000..46e4cb7
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/awk -f
+BEGIN {
+
+# Print the squares from 1 to 10 the first way
+
+       i=1;
+       while (i <= 10) {
+               printf "The square of ", i, " is ", i*i;
+               i = i+1;
+       }
+
+# do it again, using more concise code
+
+       for (i=1; i <= 10; i++) {
+               printf "The square of ", i, " is ", i*i;
+       }
+
+# now end
+exit;
+}
diff --git a/bin/awk/tests/center.awk b/bin/awk/tests/center.awk
new file mode 100755 (executable)
index 0000000..14ca019
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/awk -f
+{
+    if (length($0) < 80) {
+        prefix = "";
+        for (i = 1;i<(80-length($0))/2;i++)
+            prefix = prefix " ";
+        print prefix $0;
+    } else {
+        print;
+    }
+}
diff --git a/bin/awk/tests/count_users.awk b/bin/awk/tests/count_users.awk
new file mode 100755 (executable)
index 0000000..af339a7
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/sh
+find . -type f -print | xargs  /bin/ls -islg | \
+awk '
+BEGIN {
+# initialize all arrays used in for loop
+       count[""]=0;
+       fsize[""]=0;
+}
+{
+# validate your input
+        if (NF != 11) {
+#      ignore
+       } else {
+# assign field names
+               inode=$1;
+               flsize=$2;
+               linkcount=$4;
+               user=$5;
+               group=$6; 
+
+# should I count this file?
+
+               doit=0;
+               if (linkcount == 1) {
+# only one copy - count it
+                       doit++;
+               } else {
+# a hard link - only count first one
+                       seen[inode]++;
+                       if (seen[inode] == 1) {
+                               doit++;
+                       }
+               }
+# if doit is true, then count the file
+               if (doit ) {
+
+# total up counts in one pass
+# use description array names
+# use array index that unifies the arrays
+
+# first the counts for the number of files
+
+                       count[user " *"]++;
+                       count["* " group]++;
+                       count[user " " group]++;
+                       count["* *"]++;
+
+# then the total disk space used
+
+                       fsize[user " *"]+=flsize;
+                       fsize["* " group]+=flsize;
+                       fsize[user " " group]+=flsize;
+                       fsize["* *"]+=flsize;
+               }
+        }
+}
+END {
+# output in a form that can be sorted
+        for (i in count) {
+               if (i != "") {
+                       print fsize[i], count[i], i;
+               }
+        }
+} ' | \
+# numeric sort - biggest numbers first
+# sort fields 0 and 1 first (sort starts with 0)
+# followed by dictionary sort on fields 2 + 3
+sort +0nr -2 +2d | \
+# add header
+(echo "size count user group";cat -) |\
+# convert space to tab - makes it nice output
+# the second set of quotes contains a single tab character
+tr ' ' '       ' 
+# done - I hope you like it
diff --git a/bin/awk/tests/count_users0.awk b/bin/awk/tests/count_users0.awk
new file mode 100755 (executable)
index 0000000..484316a
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/awk -f
+{
+       username[$3]++;
+}
+END {
+       for (i in username) {
+               print username[i], i;
+       }
+}
diff --git a/bin/awk/tests/count_users1.awk b/bin/awk/tests/count_users1.awk
new file mode 100755 (executable)
index 0000000..fcae8e7
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/awk -f
+{
+       if (NF>7) {
+               username[$3]++;
+       }
+}
+END {
+       for (i in username) {
+               print username[i], i;
+       }
+}
diff --git a/bin/awk/tests/count_users2.awk b/bin/awk/tests/count_users2.awk
new file mode 100755 (executable)
index 0000000..b967e0a
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/awk -f
+BEGIN {
+       username[""]=0;
+}
+{
+       username[$3]++;
+}
+END {
+       for (i in username) {
+               if (i != "") {
+                       print username[i], i;
+               }
+       }
+}
diff --git a/bin/awk/tests/count_users3.awk b/bin/awk/tests/count_users3.awk
new file mode 100755 (executable)
index 0000000..a091f6a
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh
+find . -type f -print | xargs /bin/ls -islg | \
+awk '
+BEGIN {
+# initialize all arrays used in for loop
+       u_count[""]=0;
+       g_count[""]=0;
+       ug_count[""]=0;
+       all_count[""]=0;
+}
+{
+# validate your input
+        if (NF != 11) {
+#      ignore
+       } else {
+# assign field names
+               inode=$1;
+               size=$2;
+               linkcount=$4;
+               user=$5;
+               group=$6; 
+
+# should I count this file?
+
+               doit=0;
+               if (linkcount == 1) {
+# only one copy - count it
+                       doit++;
+               } else {
+# a hard link - only count first one
+                       seen[inode]++;
+                       if (seen[inode] == 1) {
+                               doit++;
+                       }
+               }
+# if doit is true, then count the file
+               if (doit ) {
+
+# total up counts in one pass
+# use description array names
+# use array index that unifies the arrays
+
+# first the counts for the number of files
+
+                       u_count[user " *"]++;
+                       g_count["* " group]++;
+                       ug_count[user " " group]++;
+                       all_count["* *"]++;
+
+# then the total disk space used
+
+                       u_size[user " *"]+=size;
+                       g_size["* " group]+=size;
+                       ug_size[user " " group]+=size;
+                       all_size["* *"]+=size;
+               }
+        }
+}
+END {
+# output in a form that can be sorted
+        for (i in u_count) {
+               if (i != "") {
+                       print u_size[i], u_count[i], i;
+               }
+        }
+        for (i in g_count) {
+               if (i != "") {
+                       print g_size[i], g_count[i], i;
+               }
+        }
+        for (i in ug_count) {
+               if (i != "") {
+                       print ug_size[i], ug_count[i], i;
+               }
+        }
+        for (i in all_count) {
+               if (i != "") {
+                       print all_size[i], all_count[i], i;
+               }
+        }
+} ' | \
+# numeric sort - biggest numbers first
+# sort fields 0 and 1 first (sort starts with 0)
+# followed by dictionary sort on fields 2 + 3
+sort +0nr -2 +2d | \
+# add header
+(echo "size count user group";cat -) |\
+# convert space to tab - makes it nice output
+# the second set of quotes contains a single tab character
+tr ' ' '       ' 
+# done - I hope you like it
diff --git a/bin/awk/tests/count_users_new.awk b/bin/awk/tests/count_users_new.awk
new file mode 100755 (executable)
index 0000000..11ea2be
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/sh
+find . -type f -print | xargs ls  -isl | \
+awk '
+BEGIN {
+# initialize all arrays used in for loop
+       count[""]=0;
+       fsize[""]=0;
+}
+{
+# validate your input
+        if (NF != 10) {
+                printf("I was expecting 10 columns, but found %d for the output of ls. Please tweak the script\n",NF);
+                               exit;
+#      ignore
+       } else {
+# assign field names
+               inode=$1;
+               flsize=$2;
+               linkcount=$4;
+               user=$5;
+               group=$6; 
+
+# should I count this file?
+
+               doit=0;
+               if (linkcount == 1) {
+# only one copy - count it
+                       doit++;
+               } else {
+# a hard link - only count first one
+                       seen[inode]++;
+                       if (seen[inode] == 1) {
+                               doit++;
+                       }
+               }
+# if doit is true, then count the file
+               if (doit ) {
+
+# total up counts in one pass
+# use description array names
+# use array index that unifies the arrays
+
+# first the counts for the number of files
+
+                       count[user " *"]++;
+                       count["* " group]++;
+                       count[user " " group]++;
+                       count["* *"]++;
+
+# then the total disk space used
+
+                       fsize[user " *"]+=flsize;
+                       fsize["* " group]+=flsize;
+                       fsize[user " " group]+=flsize;
+                       fsize["* *"]+=flsize;
+               }
+        }
+}
+END {
+# output in a form that can be sorted
+        for (i in count) {
+               if (i != "") {
+                       print fsize[i], count[i], i;
+               }
+        }
+} ' | \
+# numeric sort - biggest numbers first
+# sort fields 0 and 1 first (sort starts with 0)
+# followed by dictionary sort on fields 2 + 3
+sort +0nr -2 +2d | \
+# add header
+(echo "size count user group";cat -) |\
+# convert space to tab - makes it nice output
+# the second set of quotes contains a single tab character
+tr ' ' '       ' 
+# done - I hope you like it
diff --git a/bin/awk/tests/date.gawk b/bin/awk/tests/date.gawk
new file mode 100755 (executable)
index 0000000..9daae84
--- /dev/null
@@ -0,0 +1,7 @@
+#! /usr/local/bin/gawk -f
+#
+
+BEGIN {
+    format = "%a %b %e %H:%M:%S %Z %Y";
+    print strftime(format);
+}
diff --git a/bin/awk/tests/delete_passwd.awk b/bin/awk/tests/delete_passwd.awk
new file mode 100755 (executable)
index 0000000..41509ce
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/awk -f
+BEGIN {
+       FS=":";
+       OFS=":";
+}
+{
+       $2="";
+       print
+}
diff --git a/bin/awk/tests/email.awk b/bin/awk/tests/email.awk
new file mode 100755 (executable)
index 0000000..82a4bcd
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/awk -f
+{
+# field 1 is the e-mail address - perhaps
+    if ((x=index($1,"@")) > 0) {
+        username = substr($1,1,x-1);
+        hostname = substr($1,x+1,length($1));
+# the above is the same as
+#        hostname = substr($1,x+1);
+        printf("username = %s, hostname = %s\n", username, hostname);
+    }
+}
diff --git a/bin/awk/tests/include.nawk b/bin/awk/tests/include.nawk
new file mode 100755 (executable)
index 0000000..61cb2b2
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/nawk -f
+{
+# a primitive include preprocessor
+    if (($1 == "#include") && (NF == 2)) {
+# found the name of the file
+        filename = $2;
+        while (i = getline < filename ) {
+            print;
+        }
+    } else {
+        print;
+    }
+}
diff --git a/bin/awk/tests/lotto.awk b/bin/awk/tests/lotto.awk
new file mode 100755 (executable)
index 0000000..24d8706
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/nawk -f
+BEGIN {
+# Assume we want 6 random numbers between 1 and 36
+# We could get this information by reading standard input,
+# but this example will use a fixed set of parameters.
+#
+# First, initialize the seed
+    srand();
+# How many numbers are needed?
+    NUM=6;
+# what is the minimum number
+    MIN=1;
+# and the maximum?
+    MAX=36;
+# How many numbers will we find? start with 0
+    Number=0;
+    while (Number < NUM) {
+       r=int(((rand() *(1+MAX-MIN))+MIN));
+# have I seen this number before?
+       if (array[r] == 0) {
+# no, I have not
+           Number++;
+           array[r]++;
+       }
+    }
+
+# now output all numbers, in order
+    for (i=MIN;i<=MAX;i++) {
+# is it marked in the array?
+       if (array[i]) {
+# yes
+           printf("%d ",i);
+       }
+    }
+    printf("\n");
+    exit;
+}
diff --git a/bin/awk/tests/one_week_later.gawk b/bin/awk/tests/one_week_later.gawk
new file mode 100755 (executable)
index 0000000..64df6d8
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/local/bin/gawk -f
+BEGIN {
+#  get current time    
+   ts = systime();
+# the time is in seconds, so
+   one_day = 24 * 60 * 60;
+   next_week = ts + (7 * one_day);
+   format = "%a %b %e %H:%M:%S %Z %Y";
+   print strftime(format, next_week);
+   exit;
+}
diff --git a/bin/awk/tests/oneword_per_line.awk b/bin/awk/tests/oneword_per_line.awk
new file mode 100755 (executable)
index 0000000..afaa2db
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/awk -f
+BEGIN {
+       RS=" ";
+}
+{
+       print ;
+}
diff --git a/bin/awk/tests/owner_group.awk b/bin/awk/tests/owner_group.awk
new file mode 100755 (executable)
index 0000000..5821146
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/awk -f
+# parse the output of "ls -l"
+# print owner and filename
+# remember - Berkeley ls -l has 8 fields, System V has 9
+{
+       if (NF == 8) {
+               print $3, $8;
+       } else if (NF == 9) {
+               print $3, $9;
+       } 
+}
diff --git a/bin/awk/tests/print_last_field.awk b/bin/awk/tests/print_last_field.awk
new file mode 100755 (executable)
index 0000000..4d56c5a
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/awk -f
+{ print $NF; }
diff --git a/bin/awk/tests/random.awk b/bin/awk/tests/random.awk
new file mode 100755 (executable)
index 0000000..3d9a406
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/nawk -f
+# old AWK doesn't have rand() and srand()
+# only new AWK has them
+# how random is the random function?
+BEGIN {
+#      srand();
+       i=0;
+       while (i++<1000000) {
+               x=int(rand()*100 + 0.5);
+               y[x]++;
+       }
+       for (i=0;i<=100;i++) {
+               printf("%d\t%d\n",y[i],i);
+       }
+       exit;
+}
diff --git a/bin/awk/tests/trigonometry.awk b/bin/awk/tests/trigonometry.awk
new file mode 100755 (executable)
index 0000000..947f9b1
--- /dev/null
@@ -0,0 +1,119 @@
+#!/usr/bin/nawk -f
+#
+# A smattering of trigonometry...
+#
+# This AWK script plots the values from 0 to 360
+# for the basic trigonometry functions
+# but first - a review:
+#
+# (Note to the editor - the following diagram assumes
+# a fixed width font, like Courier. 
+# otherwise, the diagram  looks very stupid, instead of slightly stupid)
+#
+# Assume the following right triangle
+#
+#       Angle Y
+#
+#       |\
+#       | \
+#       |  \
+#     a |   \  c
+#       |    \
+#       |     \
+#       +-------   Angle X
+#          b
+#
+# since the triangle is a right angle, then
+#      X+Y=90
+#
+# Basic Trigonometric Functions. If you know the length
+# of 2 sides, and the angles, you can find the length of the third side.
+# Also - if you know the length of the sides, you can calculate 
+# the angles.
+#
+# The formulas are
+#
+#      sine(X) = a/c
+#      cosine(X) = b/c
+#      tangent(X) = a/b
+#
+# reciprocal functions
+#      cotangent(X) = b/a
+#      secant(X) = c/b
+#      cosecant(X) = c/a
+#
+# Example 1)
+# if an angle is 30, and the hypotenuse (c) is 10, then
+#      a = sine(30) * 10 = 5
+#      b = cosine(30) * 10 =  8.66
+#
+# The second example will be more realistic:
+#
+#      Suppose you are looking for a Christmas tree, and
+# while talking to your family, you smack into a tree
+# because your head was turned, and your kids were arguing over who
+# was going to put the first ornament on the tree.
+#
+# As you come to, you realize your feet are touching the trunk of the tree,
+# and your eyes are 6 feet from the bottom of your frostbitten toes.
+# While counting the stars that spin around your head, you also realize
+# the top of the tree is located at a 65 degree angle, relative to your eyes.
+
+# You suddenly realize the tree is 12.84 feet high! After all, 
+#      tangent(65 degrees) * 6 feet = 12.84 feet
+
+# All right, it isn't realistic. Not many people memorize the
+# tangent table, or can estimate angles that accurately. 
+# I was telling the truth about the stars spinning around the head, however. 
+
+#
+BEGIN {
+# assign a value for pi.
+       PI=3.14159;
+# select an "Ed Sullivan" number - really really big
+       BIG=999999;     
+# pick two formats
+# Keep them close together, so when one column is made larger
+# the other column can be adjusted to be the same width
+       fmt1="%7s %8s %8s %8s %10s %10s %10s %10s\n";
+# print out the title of each column
+       fmt2="%7d %8.2f %8.2f %8.2f %10.2f %10.2f %10.2f %10.2f\n";
+# old AWK wants a backslash at the end of the next line
+# to continue the print statement
+# new AWK allows you to break the line into two, after a comma
+       printf(fmt1,"Degrees","Radians","Cosine","Sine", \
+               "Tangent","Cotangent","Secant", "Cosecant");
+
+       for (i=0;i<=360;i++) {
+# convert degrees to radians
+               r = i * (PI / 180 );
+# in new AWK, the backslashes are optional
+# in OLD AWK, they are required
+               printf(fmt2, i, r, \
+# cosine of r
+               cos(r), \
+# sine of r
+               sin(r), \
+#
+# I ran into a problem when dividing by zero.
+# So I had to test for this case.
+#
+# old AWK finds the next line too complicated
+# I don't mind adding a backslash, but rewriting the
+# next three lines seems pointless for a simple lesson.
+# This script will only work with new AWK, now - sigh...
+# On the plus side, 
+#   I don't need to add those back slashes anymore
+#
+# tangent of r
+               (cos(r) == 0) ? BIG : sin(r)/cos(r), 
+# cotangent of r
+               (sin(r) == 0) ? BIG : cos(r)/sin(r), 
+# secant of r
+               (cos(r) == 0) ? BIG : 1/cos(r), 
+# cosecant of r
+               (sin(r) == 0) ? BIG : 1/sin(r));
+       }
+# put an exit here, so that standard input isn't needed.
+       exit;
+}
diff --git a/bin/awk/tests/upper_to_lower.awk b/bin/awk/tests/upper_to_lower.awk
new file mode 100755 (executable)
index 0000000..cc13071
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/awk -f
+# convert upper case letters to lower case
+BEGIN {
+    LC="abcdefghijklmnopqrstuvwxyz";
+    UC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+}
+{
+    out="";
+# look at each character
+    for(i=1;i<=length($0);i++) {
+# get the character to be checked
+        char=substr($0,i,1);
+# is it an upper case letter?
+        j=index(UC,char);
+            if (j > 0 ) {
+# found it
+                out = out substr(LC,j,1);
+            } else {
+                out = out char;
+            }
+    }
+    printf("%s\n", out);
+}    
diff --git a/bin/awk/tests/upper_to_lower.gawk b/bin/awk/tests/upper_to_lower.gawk
new file mode 100755 (executable)
index 0000000..3ae2735
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/local/bin/gawk -f
+{
+    print tolower($0);
+}
index 4e14011..c1db6ba 100644 (file)
@@ -11,7 +11,7 @@
 # To profile, put -DPROF in DEFS and -pg in CFLAGS, and recompile.
 
 DEFS=  -DTELL -DVFORK -DFILEC
-CFLAGS=        $(DEFS) -O
+CFLAGS=        $(DEFS) -O -g
 XSTR=  /usr/ucb/xstr
 AS=    as
 RM=    -rm
diff --git a/bin/csh/tests/Aliases4.csh b/bin/csh/tests/Aliases4.csh
new file mode 100755 (executable)
index 0000000..db38e04
--- /dev/null
@@ -0,0 +1,12 @@
+# sort by date:
+alias newest 'ls -lt | head -30'
+alias oldest 'ls -ltr | head -30'
+# sort by size:
+alias biggest 'ls -ls|sort -nr | head -30'
+alias smallest 'ls -ls|sort -n | head -30'
+# sort by time last used
+alias popular 'ls -lut | head -30'
+alias unpopular 'ls -lutr | head -30'
+# Sort by link time
+alias lsst 'ls -lct | head -30'
+alias lsstr 'ls -lctr | head -30'
diff --git a/bin/csh/tests/AliasesC.csh b/bin/csh/tests/AliasesC.csh
new file mode 100755 (executable)
index 0000000..444277d
--- /dev/null
@@ -0,0 +1,8 @@
+alias C 'eval "if (\!:1 !~ *.c) then \\
+       echo "Error: this is for C programs only" \\
+       echo "Extension should be .c on file \!:1, not .\!:1:e" \\
+    else \\
+       if ( -e \!:1:r ) mv \!:1:r \!:1:r.old\\
+       cc -o !:1:r !:1:r.c \!:2* \\
+    endif
+
diff --git a/bin/csh/tests/AnalyzePaths.csh b/bin/csh/tests/AnalyzePaths.csh
new file mode 100755 (executable)
index 0000000..40166e7
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/csh -f
+# this could be one script instead of three if 
+# we were using the Bourne Shell
+# But the C shell isn't very good at piping
+# commands inside of loops.
+#
+# Therefore we generate the pipe in one script, 
+# and feed AWK in another script
+GetPaths | analyze_paths.awk HOSTNAME=`hostname`
+
diff --git a/bin/csh/tests/Cheer.csh b/bin/csh/tests/Cheer.csh
new file mode 100755 (executable)
index 0000000..4cc2e13
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/csh
+
+foreach i ( 1 2 3 4 5 6 7 8 9 10 11 12 ) 
+
+       # if 9, exit
+       if ( $i == 9 ) break
+       # if odd, then don't echo
+       if ( $i % 2 == 1 ) continue
+       # Even numbers only
+       echo  $i
+       sleep 1
+end
+echo 'Who do we appreciate?'
+sleep 1; echo $USER
+sleep 1; echo $USER
+sleep 1; echo $USER
+sleep 1; echo 'Yeah!!!!!!'
diff --git a/bin/csh/tests/CreateCacheDir.sh b/bin/csh/tests/CreateCacheDir.sh
new file mode 100755 (executable)
index 0000000..e192176
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Argument #1 is the directory where we will cache
+# a filename. Actually, not a cache, but a link.
+# where is the cache directory?
+# Usage
+#     CreateCacheDir Cachedir dir1 [dir2 ...]
+# Function:
+# - Create a symbolic link in cachedir, pointing to the files in dir1, etc.
+#
+CACHE=${1:?'Target directory not defined'}
+if [ ! -d "$CACHE" ]
+then
+       echo making cache directory "$CACHE"
+       mkdir $CACHE
+fi
+
+shift
+
+# The rest of the arguments are directories to cache
+
+verbose=false # true to see what happens
+debug=false # true if you want extra information
+doit=true # false if you don't want to change anything
+
+for D in $*
+do
+    $verbose && echo caching directory $D
+    # list files, but ignore any that end with ~, or # or % (backup copies)
+    for f in `cd $D;ls|grep -v '[~#%]$'`
+    do
+        if [  -f $CACHE/$f ]
+       then
+           $debug && echo $CACHE/$f already exists
+       else
+           if [ -f $D/$f -a -x $D/$f ]
+           then
+           echo $D/$f
+               $verbose && echo ln -s $D/$f $CACHE/$f 
+               $doit && ln -s $D/$f $CACHE/$f 
+           elif [ -d $D/$f ]
+           then
+               $verbose && echo linking directory: ln -s $D/$f $CACHE/$f 
+               $doit && ln -s $D/$f $CACHE/$f 
+           else
+               $verbose && echo linking other: ln -s $D/$f $CACHE/$f 
+               $doit && ln -s $D/$f $CACHE/$f 
+           fi
+       fi
+    done
+echo you can now take $D out of your searchpath
+       
+done
+
diff --git a/bin/csh/tests/Csh - the C Shell.pdf b/bin/csh/tests/Csh - the C Shell.pdf
new file mode 100644 (file)
index 0000000..47c7d97
Binary files /dev/null and b/bin/csh/tests/Csh - the C Shell.pdf differ
diff --git a/bin/csh/tests/Csh1.csh b/bin/csh/tests/Csh1.csh
new file mode 100755 (executable)
index 0000000..7a11ef2
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/csh
+echo First argument is $1, second argument is $2
+echo All of the arguments are $*
diff --git a/bin/csh/tests/Csh2.csh b/bin/csh/tests/Csh2.csh
new file mode 100755 (executable)
index 0000000..b885b52
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/csh
+echo There are $#argv arguments
+echo First argument is $argv[1], second argument is $argv[2]
+echo All of the arguments are $argv[*]
+
diff --git a/bin/csh/tests/CshAwk.csh b/bin/csh/tests/CshAwk.csh
new file mode 100755 (executable)
index 0000000..f1e61c7
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/csh -f
+awk '{printf("%s\t%s\t%s\n",\\
+$3, $2, $1}'
+
diff --git a/bin/csh/tests/Cshrc1 b/bin/csh/tests/Cshrc1
new file mode 100644 (file)
index 0000000..d0ab409
--- /dev/null
@@ -0,0 +1,31 @@
+# Sample .cshrc file
+# Bruce Barnett 
+# This part is executed on the following occasions:
+#      1. "rsh machine command"
+#      2. "csh scriptname"
+#      3. All scripts that start with #!/bin/csh (without -f)  
+# Read the minimum .cshrc file, if there
+
+if ( -f ~/.cshrc.min ) source ~/.cshrc.min
+
+# if run as a script, then $?prompt == 0
+# if run as a remote shell, then $?prompt == 0 && $?term == 0
+# if $USER is not defined, then "~" doesn't have the proper value
+#     so bail out in this case
+
+if ( ! ( $?USER && $?prompt && $?TERM )) exit
+
+# This is an interactive shell
+
+#---Local variables
+# examples:
+#     set noclobber
+#     set myvariable = "value"
+#     set mylist = ( a b c d e f g)
+
+
+#----aliases
+if ( -f ~/.aliases ) source ~/.aliases
+
+#----Searchpath
+if ( -f ~/.path ) source ~/.path
diff --git a/bin/csh/tests/Dir_to_System.sh b/bin/csh/tests/Dir_to_System.sh
new file mode 100755 (executable)
index 0000000..31a6260
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Given a directory, return the system it is mounted on
+# If it is localhost, then echo `hostname`
+dir=${1:?'No directory specified'}
+cd $dir
+
+# On SunOS 4.x, use /usr/bin/df before /usr/5bin
+# On Solaris 5.x, use /usr/ucb/df before /usr/bin
+# Solve the problem by specifying the explicit path
+PATH=/usr/ucb:/usr/bin:/usr/5bin:$PATH
+export PATH
+
+x=`df . | grep -v Filesystem`
+# use expr to extract the system name
+server=`expr "$x" : '\(.*\)\:'`
+# with sed, I could do $server=`echo $x | sed 's/:.*//'`
+if [ "$server" ] 
+then 
+    echo $server
+else
+    hostname
+fi
+
diff --git a/bin/csh/tests/Foreach1.csh b/bin/csh/tests/Foreach1.csh
new file mode 100755 (executable)
index 0000000..1156aaa
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/echo use source to execute this command
+# variable a = filename metacharacter
+# variable b = command to execute
+
+# source this to define the alias
+if ( ! $?FOREACH_def) then
+       alias FOREACH 'set a = \!:1; \\
+               set b = (\!:2*);\\
+               source ~/source_alias/FOREACH.csh;'
+       set FOREACH_def
+else
+    echo $b | grep '#' >/dev/null
+    # remember status
+    set r = $status
+    foreach i ( $a )
+       if ( $r == 0 ) then
+           # change '#' to $i
+           set B = `echo $b | sed 's/#/'$i'/g'`
+       else
+           # Add a '$i' to the end, if it is missing
+           set B = `echo $b | sed 's/$/ '$i'/'`
+       endif
+       eval $B
+    end
+endif
+
diff --git a/bin/csh/tests/Foreach2.csh b/bin/csh/tests/Foreach2.csh
new file mode 100755 (executable)
index 0000000..00a50a5
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/echo use source to execute this command
+# variable a = filename metacharacter
+# variable b = command to execute
+
+# source this to define the alias
+if ( ! $?FOREACHr_def) then
+       alias FOREACHr 'set a = \!:1; \\
+       set b = (\!:2*); \\
+       source ~/source_alias/FOREACHr.csh;'
+       set FOREACHr_def
+else
+    echo $b | grep '#' >/dev/null
+    # remember status
+    set r = $status
+    foreach i ( $a )
+       # Here is the different part
+       set j = $i:r
+       if ( $r == 0 ) then
+           # change '#' to $j
+           set B = `echo $b | sed 's/#/'$j'/g'`
+       else
+           set B = `echo $b | sed 's/$/ '$j'/'`
+       endif
+       eval $B
+    end
+endif
+
diff --git a/bin/csh/tests/GetDate.csh b/bin/csh/tests/GetDate.csh
new file mode 100755 (executable)
index 0000000..a0cd407
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/csh
+set d = (`date`)
+# like 
+#  set d = ( Sun Feb 9 16:08:29 EST 1997 )
+# therefore
+# d[1] = day of week
+set day2="[Mm]on"
+switch ( $d[1] )
+case "*Sun": 
+       echo Sunday; breaksw
+case $day2: 
+       echo Monday;breaksw;
+case Tue: 
+       echo Tuesday;breaksw;
+case Wed: 
+       echo Wednesday;breaksw;
+case Th?: 
+       echo Thursday;breaksw;
+case F*: 
+       echo Friday;breaksw;
+case [Ss]at: 
+       echo Saturday;breaksw;
+default:
+       echo impossible condition
+       exit 2
+endsw
+
diff --git a/bin/csh/tests/GetPaths.csh b/bin/csh/tests/GetPaths.csh
new file mode 100755 (executable)
index 0000000..319058e
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/csh -f
+foreach p ( $path )
+    if ( -d $p ) then
+       set newp = (`ResolveDir $p`)
+       set server = (`Dir_to_System $p`)
+       echo "${p}:${newp}:${server}"
+    else
+       echo "${p}:?:?"
+    endif
+end
+
diff --git a/bin/csh/tests/Header.csh b/bin/csh/tests/Header.csh
new file mode 100755 (executable)
index 0000000..6007c5e
--- /dev/null
@@ -0,0 +1,140 @@
+# C shell aliases to display hosts, directories, and directory stacks
+# in the window title bar, icon string, and directory prompt
+# created by Bruce Barnett 
+# Based on the SunOS 3.5 Release notes
+# Usage:
+#      if ( -f ~/.header && -f ~/bin/Zappath ) source ~/.header
+#
+# the SP alias sets the directory prompt
+# the setbar alias changes the window title bar and icon string
+# define them here as the default case
+
+       alias SP 'set prompt="$cwd:t% "'
+       alias setbar 'echo \!* >/dev/null'
+
+# If not a sun cmdtool or shelltool, or not an X terminal, exit.
+if ( ! ( $term =~ sun* ) &&  ! ( $term =~ xterm )) goto getout
+
+# if using a raw console, don't do anything
+if ( `tty` =~ /dev/console ) goto getout
+
+# set a few variables for later
+# but only if the environment variable is not set
+
+if ( ! $?HOSTNAME ) then
+       setenv  HOSTNAME `hostname`
+endif
+
+# find the home machine
+# is there a file that has a machine name in it?
+if ( -f  ~/.display ) then
+       set mymachine = `sed -e 's/:.*//' <~/.display`
+else
+       # obviously change this to match your
+       # default system. Mine is "grymoire" - of course
+       set mymachine = "grymoire"
+# alternately, some people use "who am i"
+endif
+
+set console = '<< CONSOLE >>'
+
+# figure how how to generate escape, bell, 
+# and echo commands without a a line terminator
+# I may have done this before. If so, the variable E is set
+
+# have I executed this script before on this system?
+if ( $?E ) then
+#      echo "already set the echo variables">/dev/tty
+else if ( -f ~/.echo.${HOSTNAME} ) then
+       source ~/.echo.${HOSTNAME}
+else if ( `echo -n |wc -l`  == 0 ) then
+#      echo "built in echo is bsd" >/dev/tty
+       # then berkeley style echo
+       echo 'set ech = "echo -n"' >~/.echo.${HOSTNAME}
+       echo "set E = `echo a | tr a '\033'`" >> ~/.echo.${HOSTNAME}
+       echo "set B = `echo a | tr a '\007'`" >> ~/.echo.${HOSTNAME}
+       echo 'set N = ""' >> ~/.echo.${HOSTNAME}
+       source ~/.echo.${HOSTNAME}
+else 
+#      echo "built in echo is sysV" >/dev/tty
+       echo 'set ech = "echo"' >~/.echo.${HOSTNAME}
+       echo 'set E = "\033"' >> ~/.echo.${HOSTNAME}
+       echo 'set B = "\007"' >> ~/.echo.${HOSTNAME}
+       echo 'set N = "\c"' >> ~/.echo.${HOSTNAME}
+       source ~/.echo.${HOSTNAME}
+endif  
+
+
+# Are we using shelltool, cmdtool or xterm?
+# duplicate these aliases here to avoid problems
+if ( $term =~ sun* ) then
+       # Sun Aliases
+       alias Header '${ech}  "${E}]l\!:1${E}\${N}"'
+       alias IHeader '${ech}  "${E}]L\!:1${E}\${N}"'
+else if ( $term =~ xterm ) then
+       alias Header '${ech}  "${E}]2;\!:1${B}${N}"'
+       alias IHeader '${ech}  "${E}]1;\!:1${B}${N}"'
+endif
+
+# There are three different combinations:
+# 1) A window on a remote machine
+# 2) A window on my machine
+# 3) A console on my machine
+
+# test for each case:
+
+if (${HOSTNAME} != $mymachine ) then
+       # it is a remote machine, therefore:
+       # window title has machinename and dirs 
+       # icon has machine name only
+       # prompt has machine name+directory
+
+       alias setbar 'Header "${HOSTNAME}: `dirs | ~/bin/Zappath`" ; IHeader ${HOSTNAME}'
+
+# use either of these two lines to suit your tastes
+# the first one shows the command number and full directory path
+# The second shows just the hostname and the tail of the directory name
+
+#      alias SP 'set prompt="[\\!] ${HOSTNAME}:$cwd % "'
+       alias SP 'set prompt="${HOSTNAME}:$cwd:t% "'
+
+else if ( `tty`  == "/dev/console" ) then
+       goto getout
+else if ( `tty`  == "/dev/ttyp0" ) then
+
+# in this case an assumption is made that the first pty 
+# window to appear is the console window.
+# It's not always true, but it usually works
+
+       # window title has <<CONSOLE>> and dirs 
+       # icon has "console" only
+       # prompt has directory
+
+       alias setbar 'Header "${console} `dirs | ~/bin/Zappath`"'
+
+# both of these works - pick one that suits you
+#      alias SP 'set prompt="[\\!] $cwd % "'
+       alias SP 'set prompt="$cwd:t% "'
+else
+       # a plain window on my localhost
+       # window title has dirs 
+       # icon has cwd only
+       # prompt has directory
+       # The next line must be one line, and not split onto two
+       alias setbar 'Header "`dirs | ~/bin/Zappath `"; IHeader "`echo $cwd| ~/bin/Zappath`"'
+#      alias SP 'set prompt="[\\!] $cwd % "'
+       alias SP 'set prompt="$cwd:t% "'
+endif
+
+# redo current window
+alias . 'dirs|~/bin/Zappath;setbar;jobs'
+
+#  change cd to change prompt, window and icon title
+alias cd 'chdir \!*; SP;setbar'
+alias pushd 'pushd \!*; SP;setbar'
+alias popd 'popd \!*; SP;setbar'
+
+SP;setbar
+getout:
+# end
+
diff --git a/bin/csh/tests/OpenWin.csh b/bin/csh/tests/OpenWin.csh
new file mode 100755 (executable)
index 0000000..8fb5d99
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/csh -f
+# start OpenWindows
+setenv OPENWINHOME /usr/openwin
+source ~/.path
+$OPENWINHOME/bin/openwin
diff --git a/bin/csh/tests/Path.default b/bin/csh/tests/Path.default
new file mode 100644 (file)
index 0000000..0ec541a
--- /dev/null
@@ -0,0 +1,55 @@
+# .path.default modified for SunOS
+
+if ( ! $?HOSTNAME ) then
+    setenv HOSTNAME `hostname`
+endif
+
+# get host specific path, if there
+if ( -f ~/.path.$HOSTNAME ) then
+    source ~/.path.$HOSTNAME
+endif
+
+if ( ! $?SYSTEM ) then
+    set SYSTEM = "`uname -s`"
+endif
+
+# get system-specific searchpath, if there
+if ( -f ~/.path.$SYSTEM ) then
+    source ~/.path.$SYSTEM
+endif
+
+# define these if .path.$SYSTEM doesn't
+
+# define the system defined paths
+if (! $?SYSPATH ) then
+    set SYSPATH  = ( /usr/ucb /usr/bin /bin )
+endif
+
+# define the places a window system's files are located
+
+
+if (! $?WINPATH ) then
+    set WINPATH  = ( /usr/X11/bin /usr/X11R6/bin /usr/openwin/bin )
+endif
+
+# Private executables
+if ( ! $?MYBIN ) then
+    set MYBIN = ( ~/bin ~/bin/$SYSTEM )
+endif
+
+# local to machine
+if ( ! $?LOCALBIN ) then
+    set LOCALBIN = ( /local/bin /local/bin/$SYSTEM )
+endif
+
+#set CACHEBIN = ( $HOME/cachebin )
+set CACHEBIN = ( )
+
+#If TOTALPATH is defined, use it, else build it up from the pieces
+if ( $?TOTALPATH ) then
+    set path = ( $TOTALPATH )
+else
+    set path = ( $CACHEBIN $MYBIN $LOCALBIN $WINPATH $SYSPATH )
+#   set path = ( $CACHEBIN $MYBIN $LOCALBIN $WINPATH $SYSPATH . )
+
+endif
diff --git a/bin/csh/tests/Path.sunos b/bin/csh/tests/Path.sunos
new file mode 100644 (file)
index 0000000..1b210a2
--- /dev/null
@@ -0,0 +1,63 @@
+# .path.SunOS
+# copied from .path.default, and modified
+
+if ( ! $?SYSTEM ) then
+    set SYSTEM = "`uname -s`"
+endif
+
+# Having this here would cause an infinite loop
+# Make sure it is commented out
+#if ( -f ~/.path.$SYSTEM ) then
+#    source ~/.path.$SYSTEM
+#endif
+
+# define these if .path.$SYSTEM doesn't
+
+if ( ! $?MACHINE ) then
+    set MACHINE = "`uname -m`"
+endif
+
+if ( ! $?REV ) then
+    set REV = "`uname -r`"
+endif
+
+# define the system defined paths
+if (! $?SYSPATH ) then
+  if ( "$REV" =~ 4.[012].* ) then
+    set SYSPATH  = ( /usr/ucb /usr/bin /usr/5bin /bin  /usr/etc )
+  else if (  "$REV" =~ 5.[0-6].* ) then
+    set SYSPATH = ( /opt/SUNWspro/bin /usr/ccs/bin \
+      /usr/ucb /usr/bin /usr/sbin )
+  else
+#   How did I get here?
+    set SYSPATH  = ( /usr/ucb /usr/bin /bin )
+  endif
+endif
+
+# define the places a window system's files are located
+# I could look at DISPLAY, and change this depending on 
+# the value
+
+if (! $?WINPATH ) then
+    if ( ! $?OPENWINHOME ) then
+        setenv OPENWINHOME /usr/openwin
+    endif
+    set WINPATH  = ( $OPENWINHOME/bin )
+endif
+
+# define the places where architecture-specific binaries are
+#
+if ( ! $?MYBIN ) then
+    set MYBIN = ( ~/bin ~/$SYSTEM/$REV/$MACHINE/bin  )
+endif
+
+if ( ! $?LOCALBIN ) then
+    set LOCALBIN = ( /local/bin )
+endif
+
+#set CACHEBIN = ( )
+set CACHEBIN = ( $HOME/cachebin )
+
+# If I set this, 
+#   then the variables in .path.default will be skipped
+#set TOTALPATH = ( $CACHEBIN $MYBIN $LOCALBIN $WINPATH $SYSPATH )
diff --git a/bin/csh/tests/Path1.csh b/bin/csh/tests/Path1.csh
new file mode 100755 (executable)
index 0000000..9d4d23a
--- /dev/null
@@ -0,0 +1,8 @@
+# example .path file
+
+if ( -f ~/.path.default ) then
+    source ~/.path.default
+else
+    # this is a default searchpath
+    set path = ( ~/bin /usr/ucb /usr/bin /usr/local/bin /local/bin )
+endif
diff --git a/bin/csh/tests/ResolveDir.sh b/bin/csh/tests/ResolveDir.sh
new file mode 100755 (executable)
index 0000000..43c92e3
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Find the unique and final location of a directory
+# Usage:
+#   ResolveDir directoryname
+#
+# If the directory is called ".", return "."
+dir=${1:?'Missing argument'}
+
+[ "$dir" = "." ] && { echo "."; exit 0; }
+cd $dir  >/dev/null 2>&1 && { pwd; exit 0; }
+exit 1;
+
diff --git a/bin/csh/tests/Scripts/analyze_paths.nawk b/bin/csh/tests/Scripts/analyze_paths.nawk
new file mode 100644 (file)
index 0000000..43f96f2
--- /dev/null
@@ -0,0 +1,75 @@
+#!/usr/bin/nawk -f
+# Do this before you read any input
+BEGIN {
+  FS=":";
+}
+
+# do this for each line
+(NF==3) {
+  if ($3 ~ /\?/ ) {
+# then it is a directory that does not exist    
+    missing[$1]=1;
+    number_of_missing++;
+  } else if ( $1 ~ /\./ ) {
+# ignore it  - it is the "." directory
+  } else {
+# count how many times each directory is used
+    used_count[$2]++;
+# is it a duplicate,
+    if ($1 !~ $2) {
+      links[$2]++;
+# remember it, by catenating two strings
+      used[$2] = used[$2] " "  $1;
+    }
+
+# Is it a remote system?
+    if ($3 !~ HOSTNAME) {
+      systems[$3]++;
+# if this is the first time we have seen this directory      
+       system_to_dir[$3] = 
+          system_to_dir[$3] " " $1;
+      remote_systems++;
+    }
+  }
+
+#  printf("%s\t%s\t%s\n",$1, $2, $3);
+}
+# Do this at the end of the file
+END {
+# Any directories that do not have to be included?
+
+  if (number_of_missing>0) {
+    printf("Directories that don't exist on this system:\n");
+    for (i in missing) {
+      printf("\t%s\n", i);
+    }
+  }
+
+# how many computer systems are needed?
+
+  if (remote_systems) {
+    printf("You are dependent upon the following systems:\n");
+    for (i in systems ) {
+        printf("\tsystem %s, directories: %s\n", i, system_to_dir[i]);
+    }
+    
+  } else {
+    printf("Good! You are not dependent upon any other servers,");
+for your current directory\n");
+    printf(" except for your current directory\n");
+  }
+
+
+# What about duplicate directories?
+
+  for (i in used ) {
+    if (used_count[i]>1) {
+      printf("\nDirectory %s used %d times (symbolic links: %d)\n", 
+            i, used_count[i],  links[i]);
+      if (links[i]>0) {
+       printf("\tsymbolic links for '%s' are: %s\n", i, used[i]);
+      }
+    }
+  }
+
+}
diff --git a/bin/csh/tests/Which.csh b/bin/csh/tests/Which.csh
new file mode 100755 (executable)
index 0000000..c73912b
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/csh -f
+# A simple version of which that prints all 
+# locations that contain the command
+if ( $#argv != 1 ) then
+    echo "Wrong number of arguments - usage: 'which command'"
+    exit 1
+endif
+foreach dir ( $path )
+    if ( -x $dir/$1 ) echo $dir/$1
+end
diff --git a/bin/csh/tests/Which.sh b/bin/csh/tests/Which.sh
new file mode 100755 (executable)
index 0000000..0be81d9
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+# A simple version of which that prints all 
+# locations that contain the command
+file=${1:-"Wrong number of arguments - usage: 'which command'"}
+paths=`echo $PATH | sed '
+s/^:/.:/g
+s/:$/:./g
+s/::/:.:/g
+s/:/ /g
+'`
+for dir in $paths
+do
+    [ -x $dir/$file ] && echo $dir/$file
+done
+
diff --git a/bin/csh/tests/WordCount.csh b/bin/csh/tests/WordCount.csh
new file mode 100755 (executable)
index 0000000..ad87dcf
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/csh
+# arguments are $*
+foreach i ( $* )
+       echo file $i has `wc -l <$i` lines
+end
+
diff --git a/bin/csh/tests/Zappath.sh b/bin/csh/tests/Zappath.sh
new file mode 100755 (executable)
index 0000000..67a158d
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh 
+# Zappath: created by Bruce Barnett 
+# this script edits the output of the C shell "dirs"
+# command and shortens the strings to a compact form
+#
+# Some example editing:
+#
+#      remove the automount /tmp_mnt prefix
+#      change /usr/export/home to /home
+#      change /homedisk to /home
+#      change $HOME into ~
+#      change /home/abc to abc
+#      change /usr/etc to ./etc
+#      change */*/ABC to ./ABC 
+# one more thing:
+# must change ~ to be -
+sed '
+s:/tmp_mnt::g
+s:/usr/export/home:/home:g
+s:/homedisk:/home:g
+s:'${HOME}':~:g
+s:/home/::g
+s:/usr/:./:g
+s:[^/ ]*/[^/ ]*/:./:g
+s:~:-:g
+'
+
+
diff --git a/bin/csh/tests/myexit.csh b/bin/csh/tests/myexit.csh
new file mode 100755 (executable)
index 0000000..c8c1993
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/csh
+exit $*
+
diff --git a/bin/csh/tests/prog.csh b/bin/csh/tests/prog.csh
new file mode 100755 (executable)
index 0000000..a145eb7
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/csh
+tee /tmp/file | \
+( grep MATCH /tmp/file >/dev/null && \
+( echo BEFORE; cat - ) || ( cat - ; echo AFTER) )
+/bin/rm /tmp/file
diff --git a/bin/sed/tests/CapVowel.sed b/bin/sed/tests/CapVowel.sed
new file mode 100755 (executable)
index 0000000..495fd23
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sed -f
+s/a/A/g
+s/e/E/g
+s/i/I/g
+s/o/O/g
+s/u/U/g
+
diff --git a/bin/sed/tests/Sed - An Introduction and Tutorial.pdf b/bin/sed/tests/Sed - An Introduction and Tutorial.pdf
new file mode 100644 (file)
index 0000000..7db1c9d
Binary files /dev/null and b/bin/sed/tests/Sed - An Introduction and Tutorial.pdf differ
diff --git a/bin/sed/tests/convert2uc.sh b/bin/sed/tests/convert2uc.sh
new file mode 100755 (executable)
index 0000000..7d453b5
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+# change the first hex number to upper case format
+# uses sed twice
+# used as a filter
+# convert2uc <in >out
+sed '
+s/ /\
+/' | \
+sed ' {
+       y/abcdef/ABCDEF/
+       N
+       s/\n/ /
+}'
diff --git a/bin/sed/tests/convert2uc1.sh b/bin/sed/tests/convert2uc1.sh
new file mode 100755 (executable)
index 0000000..c39c0f7
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+# convert2uc version b
+# change the first hex number to upper case format
+# uses sed once
+# used as a filter
+# convert2uc <in >out
+sed '
+{
+# remember the line
+h
+#change the current line to upper case
+y/abcdef/ABCDEF/
+# add the old line back
+G
+# Keep the first word of the first line, 
+# and second word of the second line
+# with one humongous regular expression
+s/^\([^ ]*\) .*\n[^ ]* \(.*\)/\1 \2/
+}'
diff --git a/bin/sed/tests/convert2uc2.sh b/bin/sed/tests/convert2uc2.sh
new file mode 100755 (executable)
index 0000000..9baf26c
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+# convert2uc version b
+# change the first hex number to upper case format
+# uses sed once
+# used as a filter
+# convert2uc <in >out
+sed '
+{
+# remember the line
+h
+#change the current line to upper case
+y/abcdef/ABCDEF/
+# add the old line back
+G
+# Keep the first word of the first line, 
+# and second word of the second line
+# with one humongous regular expression
+# Carl Henrik Lunde suggested this shorter version:
+s/ .* / / # delete all but the first and last word
+}'
diff --git a/bin/sed/tests/delete_nested_parens.sh b/bin/sed/tests/delete_nested_parens.sh
new file mode 100755 (executable)
index 0000000..1fcabb9
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+sed '
+:again
+       s/([ ^I]*)//g
+       t again
+'
diff --git a/bin/sed/tests/grep3.sh b/bin/sed/tests/grep3.sh
new file mode 100755 (executable)
index 0000000..710eedb
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+# grep3 - prints out three lines around pattern
+# if there is only one argument, exit
+
+case $# in 
+       1);;
+       *) echo "Usage: $0 pattern";exit;;
+esac;
+# I hope the argument doesn't contain a /
+# if it does, sed will complain
+
+# use sed -n to disable printing 
+# unless we ask for it
+sed -n '
+'/$1/' !{
+       #no match - put the current line in the hold buffer
+       x
+       # delete the old one, which is 
+       # now in the pattern buffer
+       d
+}
+'/$1/' {
+       # a match - get last line
+       x
+       # print it
+       p
+       # get the original line back
+       x
+       # print it
+       p
+       # get the next line 
+       n
+       # print it
+       p
+       # now add three dashes as a marker
+       a\
+---
+       # now put this line into the hold buffer
+       x
+}'
diff --git a/bin/sed/tests/grep3a.sh b/bin/sed/tests/grep3a.sh
new file mode 100755 (executable)
index 0000000..c8b4c26
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+# grep3 version b - another version using the hold commands
+# if there is only one argument, exit
+
+case $# in 
+       1);;
+       *) echo "Usage: $0 pattern";exit;;
+esac;
+
+# again - I hope the argument doesn't contain a /
+
+# use sed -n to disable printing 
+
+sed -n '
+'/$1/' !{
+       # put the non-matching line in the hold buffer
+       h
+}
+'/$1/' {
+       # found a line that matches
+       # append it to the hold buffer
+       H
+       # the hold buffer contains 2 lines
+       # get the next line
+       n
+       # and add it to the hold buffer
+       H
+       # now print it back to the pattern space
+       x
+       # and print it.
+       p
+       # add the three hyphens as a marker
+       a\
+---
+}'
diff --git a/bin/sed/tests/grep3c.sh b/bin/sed/tests/grep3c.sh
new file mode 100755 (executable)
index 0000000..db28e73
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+# grep3 version c: use 'G'  instead of H
+
+# if there is only one argument, exit
+
+case $# in 
+       1);;
+       *) echo "Usage: $0 pattern";exit;;
+esac;
+
+# again - I hope the argument doesn't contain a /
+
+sed -n '
+'/$1/' !{
+       # put the non-matching line in the hold buffer
+       h
+}
+'/$1/' {
+       # found a line that matches
+       # add the next line to the pattern space
+       N
+       # exchange the previous line with the 
+       # 2 in pattern space
+       x
+       # now add the two lines back
+       G
+       # and print it.
+       p
+       # add the three hyphens as a marker
+       a\
+---
+       # remove first 2 lines
+       s/.*\n.*\n\(.*\)$/\1/
+       # and place in the hold buffer for next time
+       h
+}'
diff --git a/bin/sed/tests/grep4.sh b/bin/sed/tests/grep4.sh
new file mode 100755 (executable)
index 0000000..5425f4c
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# grep4: prints out 4 lines around pattern
+# if there is only one argument, exit
+
+case $# in 
+       1);;
+       *) echo "Usage: $0 pattern";exit;;
+esac;
+
+sed -n '
+'/$1/' !{
+       # does not match - add this line to the hold space
+       H
+       # bring it back into the pattern space
+       x
+       # Two lines would look like .*\n.*
+       # Three lines look like .*\n.*\n.*
+       # Delete extra lines - keep two
+       s/^.*\n\(.*\n.*\)$/\1/
+       # now put the two lines (at most) into 
+       # the hold buffer again
+       x
+}
+'/$1/' {
+       # matches - append the current line
+       H
+       # get the next line
+       n
+       # append that one also
+       H
+       # bring it back, but keep the current line in
+       # the hold buffer. This is the line after the pattern,
+       # and we want to place it in hold in case the next line
+       # has the desired pattern
+       x
+       # print the 4 lines
+       p
+       # add the mark
+       a\
+---
+}'
diff --git a/bin/sed/tests/grep4a.sh b/bin/sed/tests/grep4a.sh
new file mode 100755 (executable)
index 0000000..363422f
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+sed -n '
+'/$1/' !{;H;x;s/^.*\n\(.*\n.*\)$/\1/;x;}
+'/$1/' {;H;n;H;x;p;a\
+---
+}'
diff --git a/bin/sed/tests/grep_paragraph.sh b/bin/sed/tests/grep_paragraph.sh
new file mode 100755 (executable)
index 0000000..9ea610b
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+sed -n '
+# if an empty line, check the paragraph
+/^$/ b para
+# else add it to the hold buffer
+H
+# at end of file, check paragraph
+$ b para
+# now branch to end of script
+b
+# this is where a paragraph is checked for the pattern
+:para
+# return the entire paragraph
+# into the pattern space
+x
+# look for the pattern, if there - print
+/'$1'/ p
+'
diff --git a/bin/sed/tests/grep_previous.sh b/bin/sed/tests/grep_previous.sh
new file mode 100755 (executable)
index 0000000..1cd30ef
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh 
+# print previous entry
+sed -n '
+/^[ ^I]/!{
+       # line does not start with a space or tab,
+       # does it have the pattern we are interested in?
+       '/$1/' {
+               # yes it does. print three dashes
+               i\
+---
+               # get hold buffer, save current line
+               x
+               # now print what was in the hold buffer
+               p
+               # get the original line back
+               x
+       }
+       # store it in the hold buffer
+       h
+}
+# what about lines that start
+# with a space or tab?
+/^[ ^I]/ {
+       # append it to the hold buffer
+       H
+}'
diff --git a/bin/sed/tests/sed_add_comments.sh b/bin/sed/tests/sed_add_comments.sh
new file mode 100755 (executable)
index 0000000..340d374
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+sed '
+/begin/ {
+0i\
+       This is a comment\
+       It can cover several lines\
+       It will work with any version of sed
+}'
diff --git a/bin/sed/tests/sed_add_line_after_word.sh b/bin/sed/tests/sed_add_line_after_word.sh
new file mode 100755 (executable)
index 0000000..9fc0762
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+sed '
+/WORD/ a\
+Add this line after every line with WORD
+'
+
diff --git a/bin/sed/tests/sed_add_line_after_word1.sh b/bin/sed/tests/sed_add_line_after_word1.sh
new file mode 100755 (executable)
index 0000000..8404eb7
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+sed '/WORD/ a\
+Add this line after every line with WORD'
+
diff --git a/bin/sed/tests/sed_add_line_before_word.sh b/bin/sed/tests/sed_add_line_before_word.sh
new file mode 100755 (executable)
index 0000000..a64d013
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+sed '
+/WORD/ i\
+Add this line before every line with WORD
+'
+
diff --git a/bin/sed/tests/sed_addslash_before_blank.csh b/bin/sed/tests/sed_addslash_before_blank.csh
new file mode 100755 (executable)
index 0000000..b5e4cff
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/csh -f
+sed '\
+s/ /\\\\
+/' file
+
diff --git a/bin/sed/tests/sed_addslash_before_blank.sh b/bin/sed/tests/sed_addslash_before_blank.sh
new file mode 100755 (executable)
index 0000000..a2e6f09
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+sed 's/ /\\\
+/' file
+
diff --git a/bin/sed/tests/sed_bad_example.sh b/bin/sed/tests/sed_bad_example.sh
new file mode 100755 (executable)
index 0000000..7f197ad
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# this example is WRONG
+sed -e '1 {
+       d
+       s/.*//
+}'
+
diff --git a/bin/sed/tests/sed_begin_end.sh b/bin/sed/tests/sed_begin_end.sh
new file mode 100755 (executable)
index 0000000..cb4d356
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+# This is a Bourne shell script that removes #-type comments
+# between 'begin' and 'end' words.
+sed -n '
+       /begin/,/end/ {
+            s/#.*//
+            s/[ ^I]*$//
+            /^$/ d
+            p
+       }
+'
+
diff --git a/bin/sed/tests/sed_begin_end1.sh b/bin/sed/tests/sed_begin_end1.sh
new file mode 100755 (executable)
index 0000000..96386f9
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+# This is a Bourne shell script that removes #-type comments
+# between 'begin' and 'end' words.
+sed -n '
+       1,100 {
+               /begin/,/end/ {
+                    s/#.*//
+                    s/[ ^I]*$//
+                    /^$/ d
+                    p
+               }
+       }
+'
+
diff --git a/bin/sed/tests/sed_begin_end2.sh b/bin/sed/tests/sed_begin_end2.sh
new file mode 100755 (executable)
index 0000000..f7a3bc4
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+sed '
+       /begin/,/end/ !{
+            s/#.*//
+            s/[ ^I]*$//
+            /^$/ d
+            p
+       }
+'
+
diff --git a/bin/sed/tests/sed_change_line.sh b/bin/sed/tests/sed_change_line.sh
new file mode 100755 (executable)
index 0000000..716efc3
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+sed '
+/WORD/ c\
+Replace the current line with the line
+'
+
diff --git a/bin/sed/tests/sed_delete_between_two_words.sh b/bin/sed/tests/sed_delete_between_two_words.sh
new file mode 100755 (executable)
index 0000000..8fbf8b1
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+sed '
+/ONE/ {
+# append the next line
+       N
+# look for "ONE" followed by "TWO"
+       /ONE.*TWO/ {
+#      delete everything between
+               s/ONE.*TWO/ONE TWO/
+#      print
+               P
+#      then delete the first line
+               D
+       }
+}' file
+
diff --git a/bin/sed/tests/sed_delete_line_after_word.sh b/bin/sed/tests/sed_delete_line_after_word.sh
new file mode 100755 (executable)
index 0000000..ae39557
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+sed '
+/ONE/ {
+# append a line
+       N
+# if TWO found, delete the first line
+       /\n.*TWO/ D
+}' file
+
diff --git a/bin/sed/tests/sed_hereis.sed b/bin/sed/tests/sed_hereis.sed
new file mode 100755 (executable)
index 0000000..244d80a
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+echo -n 'what is the value? '
+read value
+sed  's/XXX/'"$value"'/' <<EOF
+The value is XXX
+EOF
+
diff --git a/bin/sed/tests/sed_include.sh b/bin/sed/tests/sed_include.sh
new file mode 100755 (executable)
index 0000000..163b200
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+sed '/INCLUDE/ {
+       r file
+       d
+}'
+
diff --git a/bin/sed/tests/sed_include1.sh b/bin/sed/tests/sed_include1.sh
new file mode 100755 (executable)
index 0000000..948cead
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+# watch out for a '/' in the parameter
+# use alternate search delimiter
+sed -e '\_#INCLUDE <'"$1"'>_{
+       r '"$1"'
+       d
+}'
+
diff --git a/bin/sed/tests/sed_include2.sh b/bin/sed/tests/sed_include2.sh
new file mode 100755 (executable)
index 0000000..80c8497
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+# watch out for a '/' in the parameter
+# use alternate search delimiter
+sed -e '\_#INCLUDE <'"$1"'>_{
+
+       # read the file
+       r '"$1"'
+
+       # delete any characters in the pattern space
+       # and read the next line in
+       d
+}'
+
diff --git a/bin/sed/tests/sed_insert_append_change.sh b/bin/sed/tests/sed_insert_append_change.sh
new file mode 100755 (executable)
index 0000000..8510c03
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+sed '
+/WORD/ {
+i\
+Add this line before
+a\
+Add this line after
+c\
+Change the line to this one
+}'
diff --git a/bin/sed/tests/sed_merge_two_lines.sh b/bin/sed/tests/sed_merge_two_lines.sh
new file mode 100755 (executable)
index 0000000..867015f
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+sed '=' file | \
+sed '{
+       N
+       s/\n/ /
+}'
+
diff --git a/bin/sed/tests/sed_print_line_after_word.sh b/bin/sed/tests/sed_print_line_after_word.sh
new file mode 100755 (executable)
index 0000000..814147c
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+sed -n '
+# by default - do not print anything
+/ONE/ {
+# append a line
+       N
+# if TWO found, print the first line
+       /\n.*TWO/ P
+}' file
+
diff --git a/bin/sed/tests/sed_split.sh b/bin/sed/tests/sed_split.sh
new file mode 100755 (executable)
index 0000000..dc1047c
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+tr ' ' '\012' | \
+sed ' {
+       y/abcdef/ABCDEF/
+       N
+       s/\n/ /
+}'
+
diff --git a/bin/sed/tests/sed_split_merge.sh b/bin/sed/tests/sed_split_merge.sh
new file mode 100755 (executable)
index 0000000..fc520f8
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+sed '
+s/ /\
+/' | \
+sed ' {
+       y/abcdef/ABCDEF/
+       N
+       s/\n/ /
+}'
+
diff --git a/bin/sed/tests/sed_tail.sh b/bin/sed/tests/sed_tail.sh
new file mode 100755 (executable)
index 0000000..6e5cb60
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+#print last 10 lines of file
+# First argument is the filename
+lines=`wc -l $1 | awk '{print $1}' `
+start=`expr $lines - 10`
+sed "1,$start d" $1
+
diff --git a/bin/sed/tests/sed_with_regular_expressions1.sh b/bin/sed/tests/sed_with_regular_expressions1.sh
new file mode 100755 (executable)
index 0000000..a50cb1c
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+arg=`echo "$1" | sed 's:[]\[\^\$\.\*\/]:\\\\&:g'`
+sed 's/'"$arg"'//g'
+
diff --git a/bin/sed/tests/sedgrep.sed b/bin/sed/tests/sedgrep.sed
new file mode 100755 (executable)
index 0000000..150bb95
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+sed -n 's/'"$1"'/&/p'
+
diff --git a/bin/sh/tests/0.sh b/bin/sh/tests/0.sh
new file mode 100755 (executable)
index 0000000..0e7c744
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo Hey! You forgot to specify the command!
diff --git a/bin/sh/tests/Bourne Shell Tutorial.pdf b/bin/sh/tests/Bourne Shell Tutorial.pdf
new file mode 100644 (file)
index 0000000..ec2400f
Binary files /dev/null and b/bin/sh/tests/Bourne Shell Tutorial.pdf differ
diff --git a/bin/sh/tests/CountLines0.sh b/bin/sh/tests/CountLines0.sh
new file mode 100755 (executable)
index 0000000..fe1149e
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+filename=/tmp/$0.$$
+cat "$@" | wc -l >$filename
+echo  `cat $filename` lines were found
+/bin/rm $filename
+
diff --git a/bin/sh/tests/EchoArgs.sh b/bin/sh/tests/EchoArgs.sh
new file mode 100755 (executable)
index 0000000..19728e4
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+# Scriptname: EchoArgs
+# It echoes arguments
+#First - make sure we are using the Berkeley style echoes
+PATH=/usr/ucb:$path;export PATH
+E="echo -n"
+# echo the name of the script
+${E} $0:
+# now echo each argument, but put a space
+# before the argument, and place single quotes
+# around each argument
+${E} " '${1-"?"}'"
+${E} " '${2-"?"}'"
+${E} " '${3-"?"}'"
+${E} " '${4-"?"}'"
+${E} " '${5-"?"}'"
+${E} " '${6-"?"}'"
+${E} " '${7-"?"}'"
+echo 
+
diff --git a/bin/sh/tests/ShCmdArgs.sh b/bin/sh/tests/ShCmdArgs.sh
new file mode 100755 (executable)
index 0000000..4bbd727
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+usage() {
+       echo `basename $0`: ERROR: $* 1>&2
+       echo usage: `basename $0` '[-[abc]] [-o file]' '[file ...]' 1>&2
+       exit 1
+}
+
+set -- `getopt "abco:" "$@"` || usage
+
+a= b= c= o= 
+while :
+do
+        case "$1" in
+        -a) a=1;;
+        -b) b=1;;
+        -c) c=1;;
+        -o) shift; o="$1";;
+        --) break;;
+        esac
+        shift
+done
+shift # get rid of --
+# rest of script...
diff --git a/bin/sh/tests/ShCmdArgs3.sh b/bin/sh/tests/ShCmdArgs3.sh
new file mode 100755 (executable)
index 0000000..7931f22
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+usage() {
+       echo `basename $0`: ERROR: $* 1>&2
+       echo usage: `basename $0` '[-a] [-b] [-c] [-o file] \
+               [file ...]' 1>&2
+       exit 1
+}
+
+a= b= c= o=
+
+while :
+do
+    case "$1" in
+       -a) a=1;;
+       -b) b=1;;
+       -c) c=1;;
+       -o) shift; o="$1";;
+       --) shift; break;;
+       -*) usage "bad argument $1";;
+       *) break;;
+    esac
+    shift
+done
+# rest of script...
diff --git a/bin/sh/tests/ShCmdArgs4.sh b/bin/sh/tests/ShCmdArgs4.sh
new file mode 100755 (executable)
index 0000000..850ff1f
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+usage() {
+       echo `basename $0`: ERROR: $* 1>&2
+       echo usage: `basename $0` '[-[abc]] [-o file]' '[file ...]' 1>&2
+       exit 1
+}
+
+
+inside() {
+# this function returns a TRUE if $2 is inside $1
+# I'll use a case statement, because this is a built-in of the shell, 
+# and faster.
+# I could use grep:
+#    echo $1 | grep -s "$2" >/dev/null 
+# or expr:
+#   expr "$1" : ".*$2" >/dev/null && return 0 # true
+# but case does not require another shell
+    case "$1" in
+        *$2*) return 0;;
+    esac
+    return 1;
+}
+
+
+done_options=
+more_options() {
+       # return true(0) if there are options left to parse
+       # otherwise, return false
+
+       # check the 'short-circuit' flag
+       test $done_options && return 1  # true
+
+       # how many arguments are left?
+       [ $# -eq 0 ] && return 0
+
+       # does the next argument start with a hyphen 
+       inside "$1" '-' && return 0;
+
+       # otherwise, return false
+       return 1        # false
+}
+a= b= c= o= 
+
+while more_options "$1"
+do
+    case "$1" in
+       --) done_options=1;;
+       -[abc]*)
+               inside "$1" a && a=1;
+               inside "$1" b && b=1;
+               inside "$1" c && c=1;
+               inside "$1" "[d-zA-Z]" && 
+                       usage "unknown option in $1";
+               ;;
+       -o?*)
+               # have to extract string from argument
+               o=`expr "$1" : '-o\(.*\)'`
+               ;;
+       -o)
+               [ $# -gt 1 ] || usage "-o requires a value";
+               shift
+               o="$1";;
+       -*) usage "unknown option $1";;
+    esac
+    shift      # each time around, pop off the option
+done
+# continue with script
+# ...
diff --git a/bin/sh/tests/ShCmdChk1.sh b/bin/sh/tests/ShCmdChk1.sh
new file mode 100755 (executable)
index 0000000..5e6683b
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+arg1="a.out"
+arg2=`pwd`
+arg3=$HOME
+if [ $# -gt 3 ]
+then
+fi
+
+if [ $# -eq 0 ]
+then
+       echo must specify at least one argument
+       exit 1
+else if [ $# -eq 1 ]
+then
+       arg1="$1";
+else if [ $# -eq 2 ]
+then
+       arg1="$1";
+       arg2="$2";
+else if [ $# -eq 3 ]
+then
+       arg1="$1";
+       arg2="$2";
+       arg3="$3";
+else 
+       echo too many arguments
+       exit 1
+fi
+
+mv $arg2/$arg1 $arg3
diff --git a/bin/sh/tests/ShCmdChk2.sh b/bin/sh/tests/ShCmdChk2.sh
new file mode 100755 (executable)
index 0000000..b000aaa
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+arg1="a.out"
+arg2=`pwd`
+arg3=$HOME
+if [ $# -gt 3 ]
+then
+       echo too many arguments
+       exit 1
+fi
+
+if [ $# -eq 0 ]
+then
+       echo must specify at least one argument
+       exit 1
+fi
+[ $# -ge 1 ] && arg1=$1 # do this if 1, 2 or 3 arguments
+[ $# -ge 2 ] && arg2=$2 # do this if 2 or 3 arguments
+[ $# -ge 3 ] && arg3=$3 # do this if 3 arguments
+
+mv $arg2/$arg1 $arg3
diff --git a/bin/sh/tests/ShCmdChk3.sh b/bin/sh/tests/ShCmdChk3.sh
new file mode 100755 (executable)
index 0000000..e8f52f0
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+usage() {
+       echo `basename $0`: ERROR: $* 1>&2
+       echo usage: `basename $0` 'filename [fromdir] [todir]' 1>&2
+       exit 1
+}
+arg1="a.out"
+arg2=`pwd`
+arg3=$HOME
+
+[ $# -gt 3  -o $# -lt 1 ] && usage "Wrong number of arguments"
+
+arg1=$1;shift
+[ $# -gt 0 ] && { arg2=$1;shift;}
+[ $# -gt 0 ] && { arg3=$1;shift;}
+
+mv $arg2/$arg1 $arg3
diff --git a/bin/sh/tests/ShCmdChk4.sh b/bin/sh/tests/ShCmdChk4.sh
new file mode 100755 (executable)
index 0000000..f69bf3a
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+usage() {
+       echo `basename $0`: ERROR: $* 1>&2
+       echo usage: `basename $0` 'filename [fromdir] [todir]' 1>&2
+       exit 1
+}
+arg1="a.out"
+arg2=`pwd`
+arg3=$HOME
+
+case $# in
+       0) usage "must provide at least one argument";;
+       1) arg1=$1;;
+       2) arg1=$1;arg2=$2;;
+       3) arg1=$1;arg2=$2;arg3=$3;;
+       *) usage "too many arguments";;
+
+esac
+mv $arg2/$arg1 $arg3
diff --git a/bin/sh/tests/TestEchoArgs.sh b/bin/sh/tests/TestEchoArgs.sh
new file mode 100755 (executable)
index 0000000..3187b8f
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+EchoArgs $*
+EchoArgs $@
+EchoArgs "$*"
+EchoArgs "$@"
+
diff --git a/bin/sh/tests/diskwarn.sh b/bin/sh/tests/diskwarn.sh
new file mode 100755 (executable)
index 0000000..a12193e
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Print a warning if any disk is more
+# than 95% full.
+/usr/ucb/df | tr -d '%' | awk '
+# only look at lines where the first field contains a "/"
+$1 ~ /\// {    if ($5 > 95) {
+               printf("Warning, disk %s is %4.2f%% full\n",$6,$5);
+       }
+}'
diff --git a/bin/sh/tests/moveto.sh b/bin/sh/tests/moveto.sh
new file mode 100755 (executable)
index 0000000..4603f8d
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+# scriptname: moveto
+# usage: 
+#      moveto directory files.....
+directory=${1:?"Missing"};shift
+mv $* $directory
diff --git a/bin/sh/tests/rename.sh b/bin/sh/tests/rename.sh
new file mode 100755 (executable)
index 0000000..c37c88b
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# rename: - rename a file
+# Usage: rename oldname newname
+oldname=$1
+newname=$2
+mv ${oldname:?"missing"} ${newname:?"missing"}
+
diff --git a/bin/sh/tests/rename0.sh b/bin/sh/tests/rename0.sh
new file mode 100755 (executable)
index 0000000..1b7fb23
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+# rename: - rename a file
+# Usage: rename oldname newname
+mv $1 $2
diff --git a/bin/tests/Grep.pdf b/bin/tests/Grep.pdf
new file mode 100644 (file)
index 0000000..ae5c04d
Binary files /dev/null and b/bin/tests/Grep.pdf differ
diff --git a/bin/tests/Tar.pdf b/bin/tests/Tar.pdf
new file mode 100644 (file)
index 0000000..b070525
Binary files /dev/null and b/bin/tests/Tar.pdf differ
diff --git a/bin/tests/igrep.sh b/bin/tests/igrep.sh
new file mode 100644 (file)
index 0000000..b37cb79
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+grep -i $* /dev/null
index 8b385f0..c48cede 100644 (file)
@@ -12,18 +12,18 @@ SRCS=       chdir.c chmod.c chown.c chroot.c close.c dup2.c dup.c execve.c \
        getegid.c geteuid.c getgid.c getpagesize.c getpgrp.c getpid.c \
        getppid.c getrusage.c gettimeofday.c getuid.c ioctl.c link.c linux.c \
        lseek.c lstat.c read.c readlink.c readv.c sbrk.c setpgrp.c \
-       setregid.c setreuid.c settimeofday.c sigvec.c stat.c symlink.c \
-       sync.c truncate.c umask.c unlink.c utimes.c vopen.c wait.c write.c \
-       writev.c
+       setregid.c setreuid.c settimeofday.c sigblock.c sigpause.c \
+       sigsetmask.c sigvec.c stat.c symlink.c sync.c truncate.c umask.c \
+       unlink.c utimes.c vopen.c wait.c wait3.c write.c writev.c
 
 OBJS=  chdir.o chmod.o chown.o chroot.o close.o dup2.o dup.o execve.o \
        _exit.o fchmod.o fchown.o fork.o fstat.o ftruncate.o getdtablesize.o \
        getegid.o geteuid.o getgid.o getpagesize.o getpgrp.o getpid.o \
        getppid.o getrusage.o gettimeofday.o getuid.o ioctl.o link.o linux.o \
        lseek.o lstat.o read.o readlink.o readv.o sbrk.o setpgrp.o \
-       setregid.o setreuid.o settimeofday.o sigvec.o stat.o symlink.o \
-       sync.o truncate.o umask.o unlink.o utimes.o vopen.o wait.o write.o \
-       writev.o
+       setregid.o setreuid.o settimeofday.o sigblock.o sigpause.o \
+       sigsetmask.o sigvec.o stat.o symlink.o sync.o truncate.o umask.o \
+       unlink.o utimes.o vopen.o wait.o wait3.o write.o writev.o
 
 TAGSFILE=tags
 
index c0a308b..9e03b22 100644 (file)
@@ -26,23 +26,6 @@ int getrusage(res, rip) int res; struct rusage *rip; {
                errno = htot_errno(nox_errno);
                return -1;
        }
-       rip->ru_utime.tv_sec = (time_t)ru.nox_ru_utime.nox_tv_sec;
-       rip->ru_utime.tv_usec = (time_t)ru.nox_ru_utime.nox_tv_usec;
-       rip->ru_stime.tv_sec = (time_t)ru.nox_ru_stime.nox_tv_sec;
-       rip->ru_stime.tv_usec = (time_t)ru.nox_ru_stime.nox_tv_usec;
-       rip->ru_maxrss = (long)ru.nox_ru_maxrss;
-       rip->ru_ixrss = (long)ru.nox_ru_ixrss;
-       rip->ru_idrss = (long)ru.nox_ru_idrss;
-       rip->ru_isrss = (long)ru.nox_ru_isrss;
-       rip->ru_minflt = (long)ru.nox_ru_minflt;
-       rip->ru_majflt = (long)ru.nox_ru_majflt;
-       rip->ru_nswap = (long)ru.nox_ru_nswap;
-       rip->ru_inblock = (long)ru.nox_ru_inblock;
-       rip->ru_oublock = (long)ru.nox_ru_oublock;
-       rip->ru_msgsnd = (long)ru.nox_ru_msgsnd;
-       rip->ru_msgrcv = (long)ru.nox_ru_msgrcv;
-       rip->ru_nsignals = (long)ru.nox_ru_nsignals;
-       rip->ru_nvcsw = (long)ru.nox_ru_nvcsw;
-       rip->ru_nivcsw = (long)ru.nox_ru_nivcsw;
+       htot_rusage(&ru, rip);
        return 0;
 }
index b2bcdf6..2e7593a 100644 (file)
@@ -2,14 +2,20 @@
 #include <nox_errno.h>
 #include <nox_stdlib.h>
 #include <nox_string.h>
+#include <sys/nox_resource.h>
+#include <sys/nox_signal.h>
 #include <sys/nox_types.h>
+#include <sys/nox_wait.h>
 #include <nox_unistd.h>
 
 #include <gen.h>
 #include <string.h>
 #include <sys/dir.h>
 #include <sys/errno.h>
+#include <sys/resource.h>
 #include <sys/signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #include "linux.h"
 
 nox_int ttoh_errno[] = {
@@ -241,6 +247,51 @@ void htot_stat(stat, res) struct nox_stat *stat; struct stat *res; {
        res->st_blksize = (long)stat->nox_st_blksize;
        res->st_blocks = (long)stat->nox_st_blocks;
 }
+       
+void htot_rusage(ru, res) struct nox_rusage *ru; struct rusage *res; {
+       res->ru_utime.tv_sec = (time_t)ru->nox_ru_utime.nox_tv_sec;
+       res->ru_utime.tv_usec = (time_t)ru->nox_ru_utime.nox_tv_usec;
+       res->ru_stime.tv_sec = (time_t)ru->nox_ru_stime.nox_tv_sec;
+       res->ru_stime.tv_usec = (time_t)ru->nox_ru_stime.nox_tv_usec;
+       res->ru_maxrss = (long)ru->nox_ru_maxrss;
+       res->ru_ixrss = (long)ru->nox_ru_ixrss;
+       res->ru_idrss = (long)ru->nox_ru_idrss;
+       res->ru_isrss = (long)ru->nox_ru_isrss;
+       res->ru_minflt = (long)ru->nox_ru_minflt;
+       res->ru_majflt = (long)ru->nox_ru_majflt;
+       res->ru_nswap = (long)ru->nox_ru_nswap;
+       res->ru_inblock = (long)ru->nox_ru_inblock;
+       res->ru_oublock = (long)ru->nox_ru_oublock;
+       res->ru_msgsnd = (long)ru->nox_ru_msgsnd;
+       res->ru_msgrcv = (long)ru->nox_ru_msgrcv;
+       res->ru_nsignals = (long)ru->nox_ru_nsignals;
+       res->ru_nvcsw = (long)ru->nox_ru_nvcsw;
+       res->ru_nivcsw = (long)ru->nox_ru_nivcsw;
+}
+
+int htot_wait(stat) int stat; {
+       union wait w;
+
+       if (nox_WIFEXITED(stat)) {
+               w.w_termsig = 0;
+               w.w_coredump = 0;
+               w.w_retcode = nox_WEXITSTATUS(stat);
+       }
+       else if (nox_WIFSIGNALED(stat)) {
+               w.w_termsig = htot_signo(nox_WTERMSIG(stat));
+               w.w_coredump = nox_WCOREDUMP(stat);
+               w.w_retcode = 0;
+       }
+       else if (nox_WIFSTOPPED(stat)) {
+               w.w_stopval = WSTOPPED;
+               w.w_stopsig = htot_signo(nox_WSTOPSIG(stat));
+       }
+       else {
+               nox_write((nox_int)2, "htot_wait()\n", 12);
+               nox_abort();
+       }
+       return w.w_status;
+}
 
 static void htot_direct(dirent, res) struct nox_dirent *dirent; struct direct *res; {
        res->d_ino = (ino_t)dirent->nox_d_ino;
index a66b3ae..9af06ed 100644 (file)
@@ -16,6 +16,8 @@ int htot_sigmask(nox_sigset_t *set);
 nox_mode_t ttoh_mode(unsigned m);
 unsigned htot_mode(nox_mode_t m);
 void htot_stat(struct nox_stat *statbuf, struct stat *res);
+void htot_rusage(struct nox_rusage *ru, struct rusage *res);
+int htot_wait(int stat);
 int htot_dir(nox_int fd);
 
 #endif
diff --git a/lib/libc/linux/sys/sigblock.c b/lib/libc/linux/sys/sigblock.c
new file mode 100644 (file)
index 0000000..181f300
--- /dev/null
@@ -0,0 +1,20 @@
+#include <nox_stdlib.h>
+#include <sys/nox_signal.h>
+#include <sys/nox_types.h>
+#include <nox_unistd.h>
+
+#include <sys/signal.h>
+#include <sys/types.h>
+#include "linux.h"
+
+int sigblock(m) int m; {
+       nox_sigset_t newset;
+       nox_sigset_t oldset;
+
+       ttoh_sigmask(m, &newset);
+       if (nox_sigprocmask(nox_SIG_BLOCK, &newset, &oldset)) {
+               nox_write((nox_int)2, "sigblock(): sigprocmask()\n", 26);
+               nox_abort();
+       }
+       return htot_sigmask(&oldset);
+}
diff --git a/lib/libc/linux/sys/sigpause.c b/lib/libc/linux/sys/sigpause.c
new file mode 100644 (file)
index 0000000..38ea4dc
--- /dev/null
@@ -0,0 +1,22 @@
+#include <nox_errno.h>
+#include <nox_stdlib.h>
+#include <sys/nox_signal.h>
+#include <sys/nox_types.h>
+#include <nox_unistd.h>
+
+#include <sys/errno.h>
+#include <sys/signal.h>
+#include <sys/types.h>
+#include "linux.h"
+
+int sigpause(m) int m; {
+       nox_sigset_t set;
+
+       ttoh_sigmask(m, &set);
+       if (nox_sigsuspend(&set)) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       nox_write((nox_int)2, "sigpause(): sigsuspend()\n", 25);
+       nox_abort();
+}
diff --git a/lib/libc/linux/sys/sigsetmask.c b/lib/libc/linux/sys/sigsetmask.c
new file mode 100644 (file)
index 0000000..a98768f
--- /dev/null
@@ -0,0 +1,20 @@
+#include <nox_stdlib.h>
+#include <sys/nox_signal.h>
+#include <sys/nox_types.h>
+#include <nox_unistd.h>
+
+#include <sys/signal.h>
+#include <sys/types.h>
+#include "linux.h"
+
+int sigsetmask(m) int m; {
+       nox_sigset_t newset;
+       nox_sigset_t oldset;
+
+       ttoh_sigmask(m, &newset);
+       if (nox_sigprocmask(nox_SIG_SETMASK, &newset, &oldset)) {
+               nox_write((nox_int)2, "sigsetmask(): sigprocmask()\n", 28);
+               nox_abort();
+       }
+       return htot_sigmask(&oldset);
+}
index 69edf65..6d593bd 100644 (file)
@@ -9,30 +9,36 @@
 #include "linux.h"
 
 int sigvec(c, f, m) int c; struct sigvec *f; struct sigvec *m; {
-       struct nox_sigaction act;
+       struct nox_sigaction act, *act_p;
        struct nox_sigaction oldact;
 
-       act.nox_sa_sigaction = (void (*)(nox_int, nox_siginfo_t *, void *))f->sv_handler; /* fix this later */
-       ttoh_sigmask(f->sv_mask, &act.nox_sa_mask);
-       act.nox_sa_flags = nox_SA_RESTART | nox_SA_SIGINFO;
-       if (f->sv_flags & SV_ONSTACK)
-               act.nox_sa_flags |= nox_SA_ONSTACK;
-       if (f->sv_flags & SV_INTERRUPT) {
-               nox_write((nox_int)2, "sigvec(): SV_INTERRUPT\n", 23);
-               nox_abort();
+       act_p = 0;
+       if (f) {
+               act.nox_sa_sigaction = (void (*)(nox_int, nox_siginfo_t *, void *))f->sv_handler; /* fix this later */
+               ttoh_sigmask(f->sv_mask, &act.nox_sa_mask);
+               act.nox_sa_flags = nox_SA_RESTART | nox_SA_SIGINFO;
+               if (f->sv_flags & SV_ONSTACK)
+                       act.nox_sa_flags |= nox_SA_ONSTACK;
+               if (f->sv_flags & SV_INTERRUPT) {
+                       nox_write((nox_int)2, "sigvec(): SV_INTERRUPT\n", 23);
+                       nox_abort();
+               }
+               act_p = &act;
        }
        if (c < 0 || c >= NSIG) {
                nox_write((nox_int)2, "sigvec(): out of range\n", 23);
                nox_abort();
        }
-       if (nox_sigaction(ttoh_signo[c], &act, &oldact)) {
+       if (nox_sigaction(ttoh_signo[c], act_p, &oldact)) {
                errno = htot_errno(nox_errno);
                return -1;
        }
-       m->sv_handler = (void (*)(int sig, int code, struct sigcontext *scp))oldact.nox_sa_sigaction; /* fix this later */
-       m->sv_mask = htot_sigmask(&oldact.nox_sa_mask);
-       m->sv_flags = 0;
-       if (oldact.nox_sa_flags & nox_SA_ONSTACK)
-               m->sv_flags |= SV_ONSTACK;
+       if (m) {
+               m->sv_handler = (void (*)(int sig, int code, struct sigcontext *scp))oldact.nox_sa_sigaction; /* fix this later */
+               m->sv_mask = htot_sigmask(&oldact.nox_sa_mask);
+               m->sv_flags = 0;
+               if (oldact.nox_sa_flags & nox_SA_ONSTACK)
+                       m->sv_flags |= SV_ONSTACK;
+       }
        return 0;
 }
index 8979e36..d8a65c1 100644 (file)
@@ -5,37 +5,20 @@
 #include <nox_unistd.h>
 
 #include <sys/errno.h>
+#include <sys/types.h>
 #include <sys/wait.h>
 #include "linux.h"
 
 int wait(s) int *s; {
        nox_pid_t res;
        nox_int stat;
-       union wait w;
 
        res = nox_wait(&stat);
        if (res == (nox_pid_t)-1) {
                errno = htot_errno(nox_errno);
                return -1;
        }
-       if (nox_WIFEXITED(stat)) {
-               w.w_termsig = 0;
-               w.w_coredump = 0;
-               w.w_retcode = nox_WEXITSTATUS(stat);
-       }
-       else if (nox_WIFSIGNALED(stat)) {
-               w.w_termsig = htot_signo(nox_WTERMSIG(stat));
-               w.w_coredump = nox_WCOREDUMP(stat);
-               w.w_retcode = 0;
-       }
-       else if (nox_WIFSTOPPED(stat)) {
-               w.w_stopval = WSTOPPED;
-               w.w_stopsig = htot_signo(nox_WSTOPSIG(stat));
-       }
-       else {
-               nox_write((nox_int)2, "wait(): invalid status\n", 23);
-               nox_abort();
-       }
-       *s = w.w_status;
+       if (s)
+               *s = htot_wait(stat);
        return (int)res;
 }
diff --git a/lib/libc/linux/sys/wait3.c b/lib/libc/linux/sys/wait3.c
new file mode 100644 (file)
index 0000000..9ffdffc
--- /dev/null
@@ -0,0 +1,33 @@
+#include <nox_errno.h>
+#include <sys/nox_resource.h>
+#include <sys/nox_types.h>
+#include <sys/nox_wait.h>
+
+#include <sys/errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include "linux.h"
+
+int wait3(s, o, r) int *s; int o; struct rusage *r; {
+       int opts;
+       nox_pid_t res;
+       nox_int stat;
+       struct nox_rusage ru;
+
+       opts = 0;
+       if (o & WNOHANG)
+               opts |= nox_WNOHANG;
+       if (o & WUNTRACED)
+               opts |= nox_WUNTRACED;
+       res = nox_wait3(&stat, opts, &ru);
+       if (res == (nox_pid_t)-1) {
+               errno = htot_errno(nox_errno);
+               return -1;
+       }
+       if (s)
+               *s = htot_wait(stat);
+       if (r)
+               htot_rusage(&ru, r);
+       return (int)res;
+}
index 81b4f73..70ae02f 100644 (file)
@@ -2,7 +2,7 @@
 #include <sys/file.h>
 /*#include <sys/signal.h> gen.h*/
 
-void sigpause(m) int m; {
+int sigpause(m) int m; {
        write(2, "sigpause()\n", 11);
        abort();
 }
index 469941b..55efee8 100644 (file)
@@ -147,7 +147,7 @@ int killpg __P((int pg, int s));
 int sigblock __P((int m));
 
 /* sys/sigpause.c */
-void sigpause __P((int m));
+int sigpause __P((int m));
 
 /* sys/sigreturn.c */
 int sigreturn __P((struct sigcontext *scp));
diff --git a/usr.bin/find/tests/Find.pdf b/usr.bin/find/tests/Find.pdf
new file mode 100644 (file)
index 0000000..6d0ab43
Binary files /dev/null and b/usr.bin/find/tests/Find.pdf differ