This file is indexed.

/usr/share/doc/libterm-readline-gnu-perl/examples/ptksh+ is in libterm-readline-gnu-perl 1.20-2+b1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/perl -w
#
# $Id: ptksh+,v 1.5 1997/04/01 17:15:34 ach Exp ach $
#
# POD documentation after __END__

# This program is contributed by Achim Bohnet.  It demonstrates how to
# use the callback functions in the GNU Readline Library.  This script
# is essetially equivalent with executing the following lines in
# `eg/perlsh';
#	$PerlSh::term->tkRunning(1);
#	use Tk;
#	$mw = MainWindow->new();
#
# Hiroo Hayashi

require 5.003_92;

use Tk;

# Bug: Require script does not work with all possibilities of
#      missing/existing   new MainWindow and MainLoop. Therefore
#      I have disabled it.
# Mainloop in script would be the end. No readline :-(
#require shift @ARGV if (@ARGV);


package Tk::RL;
use Tk;
use Term::ReadLine;

$name = 'ptksh+';

$mw = MainWindow->new() unless ($mw = Tk::Exists 'MainWindow');
$mw->title($name);
$mw->iconname($name);
$mw->protocol('WM_DELETE_WINDOW' => \&quit);


##### Gnu Readline Stuff #####
my $term = new Term::ReadLine $name;
my $attribs = $term->Attribs;

$term->callback_handler_install("$name> ", \&doline);

$mw->fileevent(STDIN,'readable',
	$attribs->{callback_read_char});

sub quit {
   $mw->fileevent(STDIN,'readable','');
   $term->callback_handler_remove();
   $mw->destroy;
}

my $outstream = $attribs->{outstream};
sub doline {
    my $line = shift;

    if (defined $line) {
        if ($line =~ /^p\s(.*)$/) {              
            $line = "print $1, \"!\\n\";";
        }              

        eval "{package main; $line }";
        print $outstream "$@\n" if $@;
        $term->add_history($line) if $line ne "";
        $attribs->{line_buffer} = ''; # needed for eval errors
    } else {
        quit() unless defined $line;
    }
}

# To test if Tk is not blocked:  Tk::RL::tk_active<return>
sub tk_active {
        print STDERR "I'm working behing the scene\n";
        $mw->after(1500,\&tk_active);
}
#$mw->after(1500,\&tk_active);


package main;

# be gentle if 'required' script defined $mw;
$mw = $Tk::RL::mw if not defined $mw;

MainLoop;
print "\n";

__END__

=head1 NAME

ptksh+	- Simple perl/Tk shell that uses the Gnu Readline features

=head1 SYNOPSIS

    % ptksh+
    ptksh+> $b=$mw->Button(-text=>'hello',-command=>sub{print STDERR 'hello'})
    ptksh+> $b->pack;
    ptksh+> ...
    ptksh+> ^D
    %

=head1 DESCRIPTION

This (very) simple perl/Tk shell allows you to enter perl/Tk commands
interactively.
Additionally it supports command line editing and keeps a history
of previously entered commands.  It requires C<Term-Readline-Gnu>
to be installed.

You can exit ptksh+ with ^D or using your Window Manager 'Close'
item.

=head1 SEE ALSO

Term::Readline, Term::Readline::Gnu, Tk, perldebug

=head1 AUTHOR

Achim Bohnet <F<ach@mpe.mpg.de>>, URL:L<http://www.xray.mpe.mpg.de/~ach/>

Copyright (c) 1996-1997 Achim Bohnet. All rights reserved.  This program
is free software; you can redistribute it and/or modify it under the same
terms as Perl itself.

=cut