]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/tool/bin/entry-selector
update
[l4.git] / l4 / tool / bin / entry-selector
index 433020a5cff8d5051298b310ad3b8058ae884bc0..00dc66e6ff2ec1d562c3ce60506a509bb1549c2e 100755 (executable)
@@ -1,6 +1,6 @@
 #! /usr/bin/perl -W
 #
-# (c) 2009 Technische Universität Dresden
+# (c) 2009-2011 Technische Universität Dresden
 # This file is part of TUD:OS and distributed under the terms of the
 # GNU General Public License 2.
 # Please see the COPYING-GPL-2 file for details.
@@ -16,45 +16,52 @@ BEGIN { unshift @INC, $ENV{L4DIR}.'/tool/lib'
 
 use L4::ModList;
 
-unless (defined $ARGV[0]) {
-  print "ERROR: Need to give modules file!\n";
+unless (defined $ARGV[1]) {
+  print "ERROR: Need to give command and modules file!\n";
   exit 1;
 }
 
-my @e = L4::ModList::get_entries($ARGV[0]);
+my @e = L4::ModList::get_entries($ARGV[1]);
 
-print join("\n", @e), "\n";
-
-my ($tmpfd, $tmpfilename) = tempfile();
-
-my $backtitle = '';
-if (defined $ENV{BACKTITLE})
+if ($ARGV[0] eq 'menu')
   {
-    $backtitle = $ENV{BACKTITLE};
-    $backtitle =~ s/"/\\"/g;
-    $backtitle = "--backtitle \"$backtitle\"";
-  }
+    my ($tmpfd, $tmpfilename) = tempfile();
 
-system("dialog $backtitle --title 'Entry selection' "
-       ." --menu 'Select entry to launch' 18 65 18 ".
-       join(' ', map { "$_ '$e[$_]'" } (0 .. $#e) )." 2> $tmpfilename");
+    my $backtitle = '';
+    if (defined $ENV{BACKTITLE})
+      {
+        $backtitle = $ENV{BACKTITLE};
+        $backtitle =~ s/"/\\"/g;
+        $backtitle = "--backtitle \"$backtitle\"";
+      }
 
-if ($?) {
-  print "ERROR: dialog aborted!\n";
-  exit 1;
-}
+    system("dialog $backtitle --title 'Entry selection' "
+        ." --menu 'Select entry to launch' 18 65 18 ".
+        join(' ', map { "$_ '$e[$_]'" } (0 .. $#e) )." 2> $tmpfilename");
 
-my $o;
-read $tmpfd, $o, 100;
-close $tmpfd;
-unlink $tmpfilename;
+    if ($?)
+      {
+        print "ERROR: dialog aborted!\n";
+        exit 1;
+      }
 
-chomp $o;
+    my $o;
+    read $tmpfd, $o, 100;
+    close $tmpfd;
+    unlink $tmpfilename;
 
-if ($o !~ /^\d+$/) {
-  print "ERROR: Invalid return value from dialog!\n";
-  exit 1;
-}
+    chomp $o;
+
+    if ($o !~ /^\d+$/)
+      {
+        print "ERROR: Invalid return value from dialog!\n";
+        exit 1;
+      }
 
-print STDERR $e[$o];
-exit 0;
+    print STDERR $e[$o];
+    exit 0;
+  }
+elsif ($ARGV[0] eq 'list')
+  {
+    print join("\n ", "Entries in modules file:", @e), "\n";
+  }