]> git.saurik.com Git - apple/ld64.git/blob - unit-tests/bin/rm-stale-test-logs
ld64-77.tar.gz
[apple/ld64.git] / unit-tests / bin / rm-stale-test-logs
1 #!/bin/sh
2
3 usage() {
4 echo Usage: $0 number-of-tests-logs-to-keep
5 echo where number-of-tests-logs-to-keep must be a non-zero integer
6 exit
7 }
8
9 # Usage: if no arguments
10 [ -z "$1" ] && usage
11
12 # Check if requesting 0 tests to remain!
13 [ "$1" -ne 0 ]
14
15 # don't test directly--use the result value
16 # because the command can fail for badly formed integers
17 [ $? -ne 0 ] && usage
18
19 # get the dir names of all tests in date order
20 ls -1dtr /tmp/proctor*>/tmp/all$$ 2>/dev/null
21
22 # select the last few to keep
23 tail -$1 /tmp/all$$>/tmp/keep$$
24
25 # get a list of the others
26 DELLIST=`diff /tmp/all$$ /tmp/keep$$|grep '^<'|sed -e 's/^< //'`
27
28 # any work to do?
29 if [ "$DELLIST" ]
30 then
31 echo rm -rf $DELLIST
32 rm -rf $DELLIST
33 fi
34
35 # rm the temps
36 rm /tmp/all$$ /tmp/keep$$