summaryrefslogtreecommitdiff
path: root/report/prune_results/lib.sh
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-03 22:15:56 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-03 22:15:56 +0000
commit5398949e802fc11a76776373870f47261555cc7d (patch)
tree6248011fda50db20cf8a3c413137a6db5544b28f /report/prune_results/lib.sh
parent6844944db5b0c62d7c01022270a5d0fc3b9fcdb0 (diff)
graph
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@472 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'report/prune_results/lib.sh')
-rwxr-xr-xreport/prune_results/lib.sh89
1 files changed, 89 insertions, 0 deletions
diff --git a/report/prune_results/lib.sh b/report/prune_results/lib.sh
new file mode 100755
index 00000000..ff951c64
--- /dev/null
+++ b/report/prune_results/lib.sh
@@ -0,0 +1,89 @@
+echo2() {
+ echo "$@" 1>&2
+}
+
+errorq() {
+ echo2 ERROR: "$@"
+}
+
+error() {
+ errorq "$@"
+ return 2
+}
+
+showvars_required() {
+ echo2 $0 RUNNING WITH REQUIRED VARIABLES:
+ local k
+ for k in "$@"; do
+ eval local v=\$$k
+ echo2 $k=$v
+ if [ -z "$v" ] ; then
+ errorq "required (environment or shell) variable $k not defined!"
+ return 1
+ fi
+ done
+ echo2
+}
+
+showvars_optional() {
+ echo2 RUNNING WITH OPTIONAL VARIABLES:
+ local k
+ for k in "$@"; do
+ if isset $k ; then
+ eval local v=\$$k
+ echo2 $k=$v
+ else
+ echo2 UNSET: $k
+ fi
+ done
+ echo2
+}
+
+require_files() {
+ local f
+ [ "$*" ] || error "require_files called with empty args list"
+ for f in "$@"; do
+ if ! have_file "$f" ; then
+ error "missing required file: $f"
+ return 1
+ fi
+ done
+ return 0
+}
+
+have_file() {
+ [ "$1" -a -f "$1" -a \( -z "$2" -o "$1" -nt "$2" \) -a \( -z "$require_nonempty" -o -s "$1" \) ]
+}
+
+filename_from() {
+ perl -e '
+sub superchomp {
+ my ($ref)=@_;
+ if ($$ref) {
+ $$ref =~ s|^\s+||;
+ $$ref =~ s|\s+$||;
+ $$ref =~ s|\s+| |g;
+ }
+}
+
+sub filename_from {
+ my ($fname)=@_;
+ &superchomp(\$fname);
+ $fname =~ s|[^a-zA-Z0-9_-]+|.|g;
+ $fname =~ s|^\.|_|;
+ return $fname;
+}
+
+$"=" ";print filename_from("@ARGV"),"\n"
+' -- "$@"
+}
+
+preview() {
+ tailn=${tailn:-20}
+ head -v -n $tailn "$@"
+}
+
+isset() {
+ eval local v=\${$1+set}
+ [ "$v" = set ]
+}