shithub: scripts

ref: bc762e9c9294990c0d2480295637c792363dcc8c
dir: /bin/rc/H/

View raw version
#!/usr/bin/env rc

files=()
plumber=$home/mnt/plumb/send
# Hhost=()

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

files=($1)
shift

if(~ $#Hhost 0) {
	Hhost=`{hostname}
}

# plumb file
hostfile=$files
relpath='/n/'^$"Hhost^`{pwd}
if(~ $files `{realpath $files}) {
	files='/n/'^$"Hhost^$"files
}
fileslen=`{echo -n $files | wc -c}
echo 'E
edit
'^$"relpath^'
text

'^$fileslen^'
'^$"files >>$plumber

echo 'plumbed' $hostfile >[2=1]

# wait for modification
stat=`{ls -l $hostfile}
while(sleep 1) {
	nstat=`{ls -l $hostfile}
	if(! ~ $"nstat $"stat) {
		echo $file 'modified; closing' >[2=1]
		exit
	}
}