-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathaphpfmt
executable file
·23 lines (23 loc) · 873 Bytes
/
aphpfmt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env 9 rc
fn aread { 9p read acme/$winid/$1 }
fn awrite { 9p write acme/$winid/$1 }
ftmp=`{mktemp /tmp/Aphpfmt.XXXXXX}
etmp=`{mktemp /tmp/Aphpfmt.XXXXXX}
if (aread body |php $HOME/bin/fmt.php '--config=scan' '--oracleDB=scan' -o - - $*>$ftmp >[2]$etmp) {
# Don't dirty the window if you don't have to
if (! aread body | cmp /dev/stdin $ftmp >/dev/null >[2=1]) {
echo -n mark | awrite ctl
echo -n nomark | awrite ctl
echo -n , | awrite addr
awrite data <$ftmp
echo -n mark | awrite ctl
# put us at the top of the file, rather than the bottom
echo -n '#0' | awrite addr
echo -n 'dot=addr' | awrite ctl
echo -n show | awrite ctl
}
}
if not {
sed 's|^/dev/stdin|'^$%^'|' $etmp >[1=2]
}
rm -f $ftmp $etmp