thread: Properly protect 'all_list' around insertion.
[pintos-anon] / ta-advice / cleanup
1 #! /usr/bin/perl -w
2
3 use strict;
4
5 usage () if !@ARGV;
6 (print "$ARGV[0]: chdir: $!\n"), usage () if !chdir ($ARGV[0]);
7
8 sub usage {
9     print <<EOF;
10 cleanup, cleans up extra files in submission directories.
11
12 usage: cleanup HWDIR
13 where HWDIR is a directory whose subdirectories contain grade.txt files
14 in the format produced by the submit script.
15
16 Only subdirectories whose names are entirely alphanumeric and contain
17 a grade.txt file are cleaned.  Other files and directories are unaffected.
18 EOF
19     exit 1;
20 }
21
22 for my $group (grep (/^[[:alnum:]]+$/, glob ('*'))) {
23     -e "$group/grade.txt" or next;
24
25     print "Cleaning $group...\n";
26     system ("rm -rf $group/pintos");
27     system ("rm -f $group/*~");
28 }