list Isabelle tools via perl script, which is much faster that bash plumbing, especially on Cygwin;
exclude backup files;
--- a/bin/isabelle Wed Mar 23 16:42:09 2011 +0100
+++ b/bin/isabelle Wed Mar 23 20:51:36 2011 +0100
@@ -17,8 +17,6 @@
ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
source "$ISABELLE_HOME/lib/scripts/getsettings" || exit 2
-splitarray ":" "$ISABELLE_TOOLS"; TOOLS=("${SPLITARRAY[@]}")
-
## diagnostics
@@ -30,19 +28,7 @@
echo " Start Isabelle tool NAME with ARGS; pass \"-?\" for tool specific help."
echo
echo " Available tools are:"
- for DIR in "${TOOLS[@]}"
- do
- if [ -d "$DIR" ]; then
- for TOOL in "$DIR"/*
- do
- if [ -f "$TOOL" -a -x "$TOOL" ]; then
- NAME="$(basename "$TOOL")"
- DESCRLINE="$(fgrep DESCRIPTION: "$TOOL" | sed -e 's/^.*DESCRIPTION: *//')"
- echo " $NAME - $DESCRLINE"
- fi
- done
- fi
- done
+ perl -w "$ISABELLE_HOME/lib/scripts/tools.pl"
exit 1
}
@@ -63,10 +49,15 @@
## main
+splitarray ":" "$ISABELLE_TOOLS"; TOOLS=("${SPLITARRAY[@]}")
+
for DIR in "${TOOLS[@]}"
do
TOOL="$DIR/$TOOLNAME"
- [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@"
+ case "$TOOL" in
+ *~) ;;
+ *) [ -f "$TOOL" -a -x "$TOOL" ] && exec "$TOOL" "$@" ;;
+ esac
done
fail "Unknown Isabelle tool: $TOOLNAME"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/scripts/tools.pl Wed Mar 23 20:51:36 2011 +0100
@@ -0,0 +1,37 @@
+#
+# 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 };