wm: infra

ref: a26704b4f61f20077fda74e24dc3bcb2a3b2c143
dir: /pasted/

View raw version
#!/bin/rc
# wm/pasted path
# a simple pastebin, use with aux/listen
if(! ~ $#* 1) {
	echo 'usage: wm/pasted user' >[1=2]
	exit usage
}

# not to override files
fn genrand {
	dir = $1
	rand = `{dd -quiet 1 -if /dev/random -bs 2 -count 1 | xd -1 | awk '{$1=""; print $0}' | tr -d ' '}
	if(test -e $dir/$rand){
		genrand
	}
}

genrand $1
echo $rand
read -m -c `{echo '1024 * 1024 * 5'| bc} > $dir/$rand