list Isabelle tools via perl script, which is much faster that bash plumbing, especially on Cygwin;
authorwenzelm
Wed Mar 23 20:51:36 2011 +0100 (2011-03-23)
changeset 4207796c50a4210a2
parent 42076 195566127689
child 42078 d5bf0ce40bd7
list Isabelle tools via perl script, which is much faster that bash plumbing, especially on Cygwin;
exclude backup files;
bin/isabelle
lib/scripts/tools.pl
     1.1 --- a/bin/isabelle	Wed Mar 23 16:42:09 2011 +0100
     1.2 +++ b/bin/isabelle	Wed Mar 23 20:51:36 2011 +0100
     1.3 @@ -17,8 +17,6 @@
     1.4  ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
     1.5  source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
     1.6  
     1.7 -splitarray ":" "$ISABELLE_TOOLS"; TOOLS=("${SPLITARRAY[@]}")
     1.8 -
     1.9  
    1.10  ## diagnostics
    1.11  
    1.12 @@ -30,19 +28,7 @@
    1.13    echo "  Start Isabelle tool NAME with ARGS; pass \"-?\" for tool specific help."
    1.14    echo
    1.15    echo "  Available tools are:"
    1.16 -  for DIR in "${TOOLS[@]}"
    1.17 -  do
    1.18 -    if [ -d "$DIR" ]; then
    1.19 -      for TOOL in "$DIR"/*
    1.20 -      do
    1.21 -        if [ -f "$TOOL" -a -x "$TOOL" ]; then
    1.22 -          NAME="$(basename "$TOOL")"
    1.23 -          DESCRLINE="$(fgrep DESCRIPTION: "$TOOL" | sed -e 's/^.*DESCRIPTION: *//')"
    1.24 -          echo "    $NAME - $DESCRLINE"
    1.25 -        fi
    1.26 -      done
    1.27 -    fi
    1.28 -  done
    1.29 +  perl -w "$ISABELLE_HOME/lib/scripts/tools.pl"
    1.30    exit 1
    1.31  }
    1.32  
    1.33 @@ -63,10 +49,15 @@
    1.34  
    1.35  ## main
    1.36  
    1.37 +splitarray ":" "$ISABELLE_TOOLS"; TOOLS=("${SPLITARRAY[@]}")
    1.38 +
    1.39  for DIR in "${TOOLS[@]}"
    1.40  do
    1.41    TOOL="$DIR/$TOOLNAME"
    1.42 -  [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@"
    1.43 +  case "$TOOL" in
    1.44 +    *~) ;;
    1.45 +    *) [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@" ;;
    1.46 +  esac
    1.47  done
    1.48  
    1.49  fail "Unknown Isabelle tool: $TOOLNAME"
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/lib/scripts/tools.pl	Wed Mar 23 20:51:36 2011 +0100
     2.3 @@ -0,0 +1,37 @@
     2.4 +#
     2.5 +# Author: Makarius
     2.6 +#
     2.7 +# tools.pl - list Isabelle tools with description
     2.8 +#
     2.9 +
    2.10 +use strict;
    2.11 +use warnings;
    2.12 +
    2.13 +my @tools = ();
    2.14 +
    2.15 +for my $dir (split(":", $ENV{"ISABELLE_TOOLS"})) {
    2.16 +  if (-d $dir) {
    2.17 +    if (opendir DIR, $dir) {
    2.18 +      for my $name (readdir DIR) {
    2.19 +        my $file = "$dir/$name";
    2.20 +        if (-f $file and -x $file and !($file =~ /~$/)) {
    2.21 +          if (open FILE, $file) {
    2.22 +            my $description;
    2.23 +            while (<FILE>) {
    2.24 +              if (!defined($description) and m/DESCRIPTION: *(.*)$/) {
    2.25 +                $description = $1;
    2.26 +              }
    2.27 +            }
    2.28 +            close FILE;
    2.29 +            if (defined($description)) {
    2.30 +              push(@tools, "    $name - $description\n");
    2.31 +            }
    2.32 +          }
    2.33 +        }
    2.34 +      }
    2.35 +      closedir DIR;
    2.36 +    }
    2.37 +  }
    2.38 +}
    2.39 +
    2.40 +for (sort @tools) { print };