From d325d2226cf55b63037dc62cefb7fa952d770d50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= <john@ankarstrom.se>
Date: Sun, 31 Jan 2021 14:14:05 +0000
Subject: Bind $home/bin/rc to rc/ instead of ./

---
 apropos         |  3 ---
 def             | 45 ---------------------------------------------
 draw            | 22 ----------------------
 here            |  2 --
 kwin            |  8 --------
 m               | 10 ----------
 mkdircp         |  8 --------
 mm              |  6 ------
 orig            | 10 ----------
 out             |  9 ---------
 rc/apropos      |  3 +++
 rc/def          | 45 +++++++++++++++++++++++++++++++++++++++++++++
 rc/draw         | 22 ++++++++++++++++++++++
 rc/here         |  2 ++
 rc/kwin         |  8 ++++++++
 rc/m            | 10 ++++++++++
 rc/mkdircp      |  8 ++++++++
 rc/mm           |  6 ++++++
 rc/orig         | 10 ++++++++++
 rc/out          |  9 +++++++++
 rc/patch-backup | 24 ++++++++++++++++++++++++
 rc/plumberr     |  4 ++++
 rc/riostart     |  8 ++++++++
 rc/summary      | 30 ++++++++++++++++++++++++++++++
 rc/xp           | 20 ++++++++++++++++++++
 summary         | 30 ------------------------------
 26 files changed, 209 insertions(+), 153 deletions(-)
 delete mode 100755 apropos
 delete mode 100755 def
 delete mode 100755 draw
 delete mode 100755 here
 delete mode 100755 kwin
 delete mode 100755 m
 delete mode 100755 mkdircp
 delete mode 100755 mm
 delete mode 100755 orig
 delete mode 100755 out
 create mode 100755 rc/apropos
 create mode 100755 rc/def
 create mode 100755 rc/draw
 create mode 100755 rc/here
 create mode 100755 rc/kwin
 create mode 100755 rc/m
 create mode 100755 rc/mkdircp
 create mode 100755 rc/mm
 create mode 100755 rc/orig
 create mode 100755 rc/out
 create mode 100755 rc/patch-backup
 create mode 100755 rc/plumberr
 create mode 100755 rc/riostart
 create mode 100755 rc/summary
 create mode 100755 rc/xp
 delete mode 100755 summary

diff --git a/apropos b/apropos
deleted file mode 100755
index a0a5c31..0000000
--- a/apropos
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/rc -e
-# apropos -- find man pages by name
-man -w $1 | awk -F/ '{ print $NF "(" $(NF-1) ")" }' | mc
diff --git a/def b/def
deleted file mode 100755
index 09a3f0c..0000000
--- a/def
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/rc -e
-
-# def -- find function definition
-
-flagfmt=a
-args='name [dir]'
-if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 1 2 3){
-	echo usage: $0 name [dir] >[1=2]
-	exit usage
-}
-
-name=$1
-if(~ $#* 2) wdir=$2
-if not wdir=`{pwd}
-
-files=$wdir^/*.[ch]
-if(~ $files $wdir^/'*.[ch]'){
-	echo error: no c/h files found >[1=2]
-	exit 'not found'
-}
-
-# ansi definition
-if(~ $flaga 1){
-	r=`{
-		echo 'X ,x/[\n 	]\**'^$name^'\(.*\)([ 	]*\/\*.*\*\/)?\n{/-+=' |
-		sam -d $files >[2=1] |
-		awk -F'[ ;]' '
-			/^ -\. / { file = $3; next }
-			/^ -  / { file = $4; next }
-			{ print file ":" $1; exit }
-	'}
-}
-
-# style(1) definition
-if not{
-	r=`{grep -n '^'^$name^'\(' $files | awk -F: '{print $1 ":" $2; exit}'}
-}
-
-# success
-if(! ~ $r '')
-	echo $r
-
-# try to find macro instead
-if not
-	grep -n '^#define[ 	]'^$name^'\(' $files | awk -F: '{print $1 ":" $2; exit}'
diff --git a/draw b/draw
deleted file mode 100755
index f450741..0000000
--- a/draw
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/rc
-
-# draw -- run program in window system's namespace
-
-if(~ $wsys ''){
-	echo $0: '$wsys' not defined >[1=2]
-	exit 'wsys not defined'
-}
-
-flagfmt='a args'
-args='command ...'
-if(! ifs=() eval `{aux/getflags $*}){
-	aux/usage
-	exit usage
-}
-
-rfork n
-unmount /mnt/acme /dev >[2]/dev/null
-unmount $wsys /dev >[2]/dev/null
-mount $wsys /mnt/wsys 'new '$flaga
-bind -b /mnt/wsys /dev
-exec $*
diff --git a/here b/here
deleted file mode 100755
index c8199e8..0000000
--- a/here
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/rc
-exec window -cd `{pwd} $*
diff --git a/kwin b/kwin
deleted file mode 100755
index 2448503..0000000
--- a/kwin
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/rc -e
-
-# kwin -- show kernel messages
-
-echo bottom > /dev/wctl
-echo scroll > /dev/wctl
-echo -n errors > /dev/label
-cat /dev/kprint
diff --git a/m b/m
deleted file mode 100755
index 1da3add..0000000
--- a/m
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/rc -e
-# m -- open man page(s) for command
-m=`{apropos $1}
-n=()
-for(p in $m)
-	if(~ $p *'(1)' *'(4)')
-		n=($n $p)
-if(~ $#n 0)
-	exit 'no manual page'
-plumb $n
diff --git a/mkdircp b/mkdircp
deleted file mode 100755
index 2236f24..0000000
--- a/mkdircp
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/rc -e
-if(! ~ $#* 2){
-	echo usage: $0 fromdir todir >[1=2]
-	exit usage
-}
-if(! test -d $2)
-	mkdir $2
-exec dircp $1 $2
diff --git a/mm b/mm
deleted file mode 100755
index a0aaca7..0000000
--- a/mm
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/rc -e
-# mm -- multi-man
-m=`{apropos $1}
-if(~ $#m 0)
-	exit 'no manual page'
-plumb $m
diff --git a/orig b/orig
deleted file mode 100755
index df991ff..0000000
--- a/orig
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/rc
-ifs='
-'
-
-if(! test -d /n/sources/plan9){
-	rfork n
-	9fs sources
-}
-
-exec plumb /n/sources/plan9`{cleanname -d `{pwd} $1}
diff --git a/out b/out
deleted file mode 100755
index 71fb5f0..0000000
--- a/out
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/rc
-if(~ $#* 0)
-	f=8.out
-if not
-	f=$1
-if(test -e $f)
-	exec window -cd `{pwd} rc -c 'plumber; exec '^$f
-echo error: $f does not exist >[1=2]
-exit 'file not found'
diff --git a/rc/apropos b/rc/apropos
new file mode 100755
index 0000000..a0a5c31
--- /dev/null
+++ b/rc/apropos
@@ -0,0 +1,3 @@
+#!/bin/rc -e
+# apropos -- find man pages by name
+man -w $1 | awk -F/ '{ print $NF "(" $(NF-1) ")" }' | mc
diff --git a/rc/def b/rc/def
new file mode 100755
index 0000000..09a3f0c
--- /dev/null
+++ b/rc/def
@@ -0,0 +1,45 @@
+#!/bin/rc -e
+
+# def -- find function definition
+
+flagfmt=a
+args='name [dir]'
+if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 1 2 3){
+	echo usage: $0 name [dir] >[1=2]
+	exit usage
+}
+
+name=$1
+if(~ $#* 2) wdir=$2
+if not wdir=`{pwd}
+
+files=$wdir^/*.[ch]
+if(~ $files $wdir^/'*.[ch]'){
+	echo error: no c/h files found >[1=2]
+	exit 'not found'
+}
+
+# ansi definition
+if(~ $flaga 1){
+	r=`{
+		echo 'X ,x/[\n 	]\**'^$name^'\(.*\)([ 	]*\/\*.*\*\/)?\n{/-+=' |
+		sam -d $files >[2=1] |
+		awk -F'[ ;]' '
+			/^ -\. / { file = $3; next }
+			/^ -  / { file = $4; next }
+			{ print file ":" $1; exit }
+	'}
+}
+
+# style(1) definition
+if not{
+	r=`{grep -n '^'^$name^'\(' $files | awk -F: '{print $1 ":" $2; exit}'}
+}
+
+# success
+if(! ~ $r '')
+	echo $r
+
+# try to find macro instead
+if not
+	grep -n '^#define[ 	]'^$name^'\(' $files | awk -F: '{print $1 ":" $2; exit}'
diff --git a/rc/draw b/rc/draw
new file mode 100755
index 0000000..f450741
--- /dev/null
+++ b/rc/draw
@@ -0,0 +1,22 @@
+#!/bin/rc
+
+# draw -- run program in window system's namespace
+
+if(~ $wsys ''){
+	echo $0: '$wsys' not defined >[1=2]
+	exit 'wsys not defined'
+}
+
+flagfmt='a args'
+args='command ...'
+if(! ifs=() eval `{aux/getflags $*}){
+	aux/usage
+	exit usage
+}
+
+rfork n
+unmount /mnt/acme /dev >[2]/dev/null
+unmount $wsys /dev >[2]/dev/null
+mount $wsys /mnt/wsys 'new '$flaga
+bind -b /mnt/wsys /dev
+exec $*
diff --git a/rc/here b/rc/here
new file mode 100755
index 0000000..c8199e8
--- /dev/null
+++ b/rc/here
@@ -0,0 +1,2 @@
+#!/bin/rc
+exec window -cd `{pwd} $*
diff --git a/rc/kwin b/rc/kwin
new file mode 100755
index 0000000..2448503
--- /dev/null
+++ b/rc/kwin
@@ -0,0 +1,8 @@
+#!/bin/rc -e
+
+# kwin -- show kernel messages
+
+echo bottom > /dev/wctl
+echo scroll > /dev/wctl
+echo -n errors > /dev/label
+cat /dev/kprint
diff --git a/rc/m b/rc/m
new file mode 100755
index 0000000..1da3add
--- /dev/null
+++ b/rc/m
@@ -0,0 +1,10 @@
+#!/bin/rc -e
+# m -- open man page(s) for command
+m=`{apropos $1}
+n=()
+for(p in $m)
+	if(~ $p *'(1)' *'(4)')
+		n=($n $p)
+if(~ $#n 0)
+	exit 'no manual page'
+plumb $n
diff --git a/rc/mkdircp b/rc/mkdircp
new file mode 100755
index 0000000..2236f24
--- /dev/null
+++ b/rc/mkdircp
@@ -0,0 +1,8 @@
+#!/bin/rc -e
+if(! ~ $#* 2){
+	echo usage: $0 fromdir todir >[1=2]
+	exit usage
+}
+if(! test -d $2)
+	mkdir $2
+exec dircp $1 $2
diff --git a/rc/mm b/rc/mm
new file mode 100755
index 0000000..a0aaca7
--- /dev/null
+++ b/rc/mm
@@ -0,0 +1,6 @@
+#!/bin/rc -e
+# mm -- multi-man
+m=`{apropos $1}
+if(~ $#m 0)
+	exit 'no manual page'
+plumb $m
diff --git a/rc/orig b/rc/orig
new file mode 100755
index 0000000..df991ff
--- /dev/null
+++ b/rc/orig
@@ -0,0 +1,10 @@
+#!/bin/rc
+ifs='
+'
+
+if(! test -d /n/sources/plan9){
+	rfork n
+	9fs sources
+}
+
+exec plumb /n/sources/plan9`{cleanname -d `{pwd} $1}
diff --git a/rc/out b/rc/out
new file mode 100755
index 0000000..71fb5f0
--- /dev/null
+++ b/rc/out
@@ -0,0 +1,9 @@
+#!/bin/rc
+if(~ $#* 0)
+	f=8.out
+if not
+	f=$1
+if(test -e $f)
+	exec window -cd `{pwd} rc -c 'plumber; exec '^$f
+echo error: $f does not exist >[1=2]
+exit 'file not found'
diff --git a/rc/patch-backup b/rc/patch-backup
new file mode 100755
index 0000000..55d852e
--- /dev/null
+++ b/rc/patch-backup
@@ -0,0 +1,24 @@
+#!/bin/rc -e
+
+if(! test -d /n/sources/patch){
+	rfork n
+	9fs sources
+}
+
+rsys=`{ndb/query ipnet plan9 cifs}
+if(! test -d /n/$rsys/misc){
+	if(ip/ping -n 1 '$cifs' >/dev/null){
+		rfork n
+		cifs -m /n/$rsys '$cifs'
+	}
+	if not{
+		echo $rsys not available >[1=2]
+		exit 'destination not available'
+	}
+}
+
+if(! test -d /n/$rsys/misc/9patch)
+	mkdir /n/$rsys/misc/9patch
+
+echo dircp /n/sources/patch /n/$rsys/misc/9patch
+exec dircp /n/sources/patch /n/$rsys/misc/9patch
diff --git a/rc/plumberr b/rc/plumberr
new file mode 100755
index 0000000..8f142be
--- /dev/null
+++ b/rc/plumberr
@@ -0,0 +1,4 @@
+#!/bin/rc -e
+cat > /tmp/plumberr
+if(! ~ `{ls -l /tmp/plumberr | awk '{print $6}'} 0)
+	B /tmp/plumberr
diff --git a/rc/riostart b/rc/riostart
new file mode 100755
index 0000000..9812b84
--- /dev/null
+++ b/rc/riostart
@@ -0,0 +1,8 @@
+#!/bin/rc
+window 0,224,161,347 winwatch -r 1000 -e '^(winwatch|stats|errors)'
+window 0,113,161,230 kwin
+window 0,0,161,117 stats -lmisce
+window -miny 130
+
+# run a system shell on the serial console
+~ $#console 0 || window -scroll console
diff --git a/rc/summary b/rc/summary
new file mode 100755
index 0000000..b527afd
--- /dev/null
+++ b/rc/summary
@@ -0,0 +1,30 @@
+#!/bin/rc -e
+
+flagfmt='o,h,x,a'
+if(! ifs=() eval `{aux/getflags $*}){
+	aux/usage
+	exit usage
+}
+if(~ $#flago$#flagh$#flagx 000){
+	flago=1
+	flagh=1
+}
+
+cat $home/notes | awk '
+	/^   o	/ { o = o $0 "\n"; mode = "o"; next } # important
+	/^   -	/ { h = h $0 "\n"; mode = "h"; next } # normal
+	/^   x	/ { x = x $0 "\n"; mode = "x"; next } # done
+	/^	/ {
+		if (! ENVIRON["flaga"]) next
+		if (mode == "o") o = o $0 "\n"
+		if (mode == "h") h = h $0 "\n"
+		if (mode == "x") x = x $0 "\n"
+		next
+	}
+	{ mode = "" }
+	END {
+		if (ENVIRON["flago"]) printf "%s", o
+		if (ENVIRON["flagh"]) printf "%s", h
+		if (ENVIRON["flagx"]) printf "%s", x
+	}
+'
diff --git a/rc/xp b/rc/xp
new file mode 100755
index 0000000..07c637f
--- /dev/null
+++ b/rc/xp
@@ -0,0 +1,20 @@
+#!/bin/rc -e
+
+# xp -- safer and more useful cp
+# for copying directories, use dxp (or perhaps -r?)
+
+flagfmt='t directory'
+args='files ... | from to'
+if(! ifs=() eval `{aux/getflags $*} || ~ $#* 0){
+	aux/usage
+	exit usage
+}
+
+if(~ $flagt '') {
+	if(! ~ $#* 2){
+		echo must be two arguments only without -t >[1=2]
+		aux/usage
+		exit usage
+	}
+	exec cp $1 $2
+}
diff --git a/summary b/summary
deleted file mode 100755
index b527afd..0000000
--- a/summary
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/rc -e
-
-flagfmt='o,h,x,a'
-if(! ifs=() eval `{aux/getflags $*}){
-	aux/usage
-	exit usage
-}
-if(~ $#flago$#flagh$#flagx 000){
-	flago=1
-	flagh=1
-}
-
-cat $home/notes | awk '
-	/^   o	/ { o = o $0 "\n"; mode = "o"; next } # important
-	/^   -	/ { h = h $0 "\n"; mode = "h"; next } # normal
-	/^   x	/ { x = x $0 "\n"; mode = "x"; next } # done
-	/^	/ {
-		if (! ENVIRON["flaga"]) next
-		if (mode == "o") o = o $0 "\n"
-		if (mode == "h") h = h $0 "\n"
-		if (mode == "x") x = x $0 "\n"
-		next
-	}
-	{ mode = "" }
-	END {
-		if (ENVIRON["flago"]) printf "%s", o
-		if (ENVIRON["flagh"]) printf "%s", h
-		if (ENVIRON["flagx"]) printf "%s", x
-	}
-'
-- 
cgit v1.2.3