~moody/rc

ref: f396e3ee1b1a183cd6b755d1b0a20d2abebc2985 rc/np -rwxr-xr-x 693 bytes
f396e3eeMoody Initial commit 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/rc
rfork e
if(test $#* -lt 1){
	echo 'Usage: np name' >[1=2]
	exit
}

prog=$1
dir=$home/src/^$prog
shift

if(test -d $dir){
	exit 'dir already exists'
}
mkdir $dir
sed 's/PROG/'^$prog^'/g' >$dir^'/mkfile' <<.
</$$objtype/mkfile
BIN=$home/bin/$objtype

TARG=PROG
OFILES=PROG.$$O

</sys/src/cmd/mkone
.

includes=`{
	{
		echo #include <u.h>
		echo #include <lib.h>
		for(i in $*){
			man 2 $i 
		} | grep '#include'
	} | awk '{ a[$0] = 1 } END{for(x in a) print x}' | sed 's/^[ 	]+//g;/^$/d'
}


sed '/^$/i\
'^$"includes <{
echo
echo 'void'
echo 'main(int argc, char *argv[])'
echo '{'
echo '}'
} | sed 's/> ?/>\n/g' | sed '/^$/d' | sed '/void/i\
' | sed 's/{/{\n/' > $dir^'/'^$prog^'.c'