lib/scripts/tools.pl
author wenzelm
Wed, 23 Mar 2011 20:51:36 +0100
changeset 42077 96c50a4210a2
child 42124 7519c7c33017
permissions -rw-r--r--
list Isabelle tools via perl script, which is much faster that bash plumbing, especially on Cygwin; exclude backup files;

#
# Author: Makarius
#
# tools.pl - list Isabelle tools with description
#

use strict;
use warnings;

my @tools = ();

for my $dir (split(":", $ENV{"ISABELLE_TOOLS"})) {
  if (-d $dir) {
    if (opendir DIR, $dir) {
      for my $name (readdir DIR) {
        my $file = "$dir/$name";
        if (-f $file and -x $file and !($file =~ /~$/)) {
          if (open FILE, $file) {
            my $description;
            while (<FILE>) {
              if (!defined($description) and m/DESCRIPTION: *(.*)$/) {
                $description = $1;
              }
            }
            close FILE;
            if (defined($description)) {
              push(@tools, "    $name - $description\n");
            }
          }
        }
      }
      closedir DIR;
    }
  }
}

for (sort @tools) { print };