summaryrefslogtreecommitdiff
path: root/rc/bin/B
blob: 56cccaa38e5ed6297cfaba964dc3700f3703868e (plain)
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
#!/bin/rc

rfork e

files=()
dest=()

if(~ $#* 0){
	echo usage: B file ... >[1=2]
	exit usage
}

if(test -f /mnt/plumb/edit || test -f /mnt/term/mnt/plumb/edit){
	for(i)
		plumb -s B -d edit $i
	exit
}

# using sam srv file

for(i)
	switch($i){
	case /*
		files = ( $files $i )
	case *
		files = ( $files `{cleanname `{pwd}^/$i} )
	}

if(test -f /mnt/term/srv/sam.$user) dest = /mnt/term/srv/sam.$user
if not if(test -f /srv/sam.$user) dest = /srv/sam.$user
if not {
	echo B: can''''t find sam server file >[1=2]
	exit open
}

switch($files){
case *:*
	for(i in $files)
		echo $i | sed 's/^/B /;s/:([0-9]+)$/\n\1/g' >> $dest
case *
	echo B $files >> $dest
}