Plan 9 from Bell Labs’s /usr/web/sources/contrib/josh/rc/µb/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(~ $#µblog 1)
	url=$µblog
if(~ $#flagh 1)
	url=$flagh
if(! ~ $#url 1){
	echo 'set $µblog 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.json
ofile=/dev/null
if(~ $#flagd 1)
	ofile=/fd/2
hget -p 'source=µb/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 [email protected].