shithub: bin.rc

ref: 1bab993af3da2ba2ee9e84d8602c9ae67f7c58d1
dir: /bin/vol/

View raw version
#!/bin/rc -e
rfork e
fn usage {>[1=2] echo 'usage:' $usage && exit 'usage'}
usage='vol [-+] | [+-]vol | vol'

fn expr {
	switch($2){
	case [-+][0-9]*
		echo $1 $2 | bc
	case - +
		echo $1 $2 5 | bc
	case *
		echo $2
	}
}

if(~ $#* 0)
	usage

vol=`{awk '/master/ {print $2, $3}' </dev/volume}
switch($#*){
case 1
	vol=(`{expr $vol(1) $1})
case 2
	vol=(`{expr $vol(1) $1} `{expr $vol(2) $2})
}
echo master $vol
echo master $vol >/dev/volume