Plan 9 from Bell Labs’s /usr/web/sources/contrib/josh/rc/mb/write

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

# Based on 'tweet' by anothy.

rfork en

flagfmt='d,h url'
args='[text]'
if(! ifs=() eval `{aux/getflags $*}){
	aux/usage
	exit usage
}

#url=https://identi.ca/api
if(~ $#mbapiurl 1)
	url=$mbapiurl
if(~ $#flagh 1)
	url=$flagh
if(! ~ $#url 1){
	echo 'set $mbapiurl or give -h url' >[1=2]
	exit usage
}

if(~ $#* 0)
	msg=`{read}
if not
	msg=$"*

MAXC=140
msgc=`{echo -n $msg |wc -r}
if(! ~ $msgc `{seq $MAXC}) {
	echo Not posted. Wanted ≤ $MAXC characters, got $msgc. >[1=2]
	exit length
}

q=statuses/update.xml
ofile=/dev/null
if(~ $#flagd 1)
	ofile=/fd/2
hget -p 'source=mb/write&status='^$"msg $url/$q > $ofile

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.