-
Notifications
You must be signed in to change notification settings - Fork 16
/
run.sh
executable file
·54 lines (50 loc) · 1.43 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
set -eu
set -o pipefail
function run {
language="$1"
prog="$2"
input="$3"
out_file="/tmp/yaml-sucks.out.json"
err_file="/tmp/yaml-sucks.err.txt"
$prog < $input > $out_file 2> $err_file ||:
( if [ -s $err_file ]; then
echo ':x:'
# cat $err_file >&2
cat $err_file
else
echo -n "<pre><code class='$language'>"
cat $out_file
echo '</code></pre>'
fi
)
}
( cat preamble.md
echo '<table>'
echo '<tr>'
echo '<th>YAML source</th>'
echo '<th>yaml2json.hs</th>'
echo '<th>yaml2json.pl</th>'
echo '<th>yaml2json.py</th>'
echo '<th>yaml2json.rb</th>'
echo '<th>rq</th>'
echo '</tr>'
for input in inputs/*.yaml; do
echo '<tr>'
echo '<td>'
run '' cat $input
echo '</td><td>'
run haskell ./yaml2json.hs $input
echo '</td><td>'
run perl ./yaml2json.pl $input
echo '</td><td>'
run python ./yaml2json.py $input
echo '</td><td>'
run ruby ./yaml2json.rb $input
echo '</td><td>'
run '' 'rq -y -J --format indented' $input
echo '</td>'
echo '</tr>'
done
echo '</table>'
) > README.md