-
Notifications
You must be signed in to change notification settings - Fork 1
/
rummy
executable file
·55 lines (47 loc) · 1007 Bytes
/
rummy
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
55
#!/usr/bin/env bash
#
# Synopsis:
# Find all blobs with known unknowns, defaulting to all schemas
# Usage:
# $ rummy | cut -f2 | xargs bio-file
#
# $ rummy
# libxml2\tsha:01871af3ae0a6af9096c3155c5741453b8eb83b8
# jsonorg\tsha:fef573f2fd3c76002e71f048c120abc0e0a3965f
#
# $ rummy | cut -f2 | sort -u
#
PROG=$(basename $0)
trap '' PIPE
die()
{
echo "$PROG: ERROR: $@" >&2
exit 1
}
test -n "$SETSPACE_ROOT" || die "env variable not defined: SETSPACE_ROOT"
cd $SETSPACE_ROOT || die "cd $SETSPACE_ROOT failed"
psql_rummy()
{
local SCH;
SCH=$1
psql -c "SELECT blob FROM $SCH.rummy;" \
--tuples-only \
--no-psqlrc \
--quiet |
sed '/^ *$/d' |
sed 's/ //g' |
sed "s/.*/$SCH &/"
STATUS=${PIPESTATUS[*]}
test "$STATUS" = '0 0 0 0' ||
die "psql rummy $SQL | sed failed: exit status=$STATUS"
}
if [ $# = 0 ]; then
find-schema | while read SCH; do
psql_rummy $SCH || exit
done
exit 0
fi
while [ "$1" ]; do
psql_rummy "$1" || exit
shift
done