Running a script with cyradm throwing ReadLine errors
Binarus
lists at binarus.de
Tue Dec 18 13:00:46 EST 2018
Dear ellie,
On 17.12.2018 23:57, ellie timoney wrote:
> Hi Binarus,
>
>> Could anybody please tell me what I might do wrong here?
>
> This kind of smells like maybe your system has two versions of perl installed (or two versions of Term::ReadLine, or maybe even two versions of Cyrus::IMAP::Shell), and they're getting in each other's way?
>
> I'm having a quick glance at the (2.5.10) source of Cyrus::IMAP::Shell and this caught my eye:
>
>> # ugh. ugh. suck. aieee.
>> my $use_rl = 'Cyrus::IMAP::DummyReadline';
>> {
>> if (eval { require Term::ReadLine; }) {
>> $use_rl = 'Term::ReadLine';
>> }
>> }
I have done some further investigations (very roughly because I don't
have the time at the moment). It seems that the code which parses the
command line and the run parameters in Cyrus::IMAP::Shell is buggy (or
at least not prepared to handle Term::ReadLine::Gnu).
As a proof, I have reinstalled Term::ReadLine:Gnu and verified that the
problem was showing again.
Then I have replaced the following code in Cyrus::IMAP::Shell
# trivial; wrapper for _run with correct setup
sub run {
my $cyradm;
_run(\$cyradm, [*STDIN, *STDOUT, *STDERR], *__DATA__);
}
by the following code:
# trivial; wrapper for _run with correct setup
sub run {
my $cyradm;
open(*__DATA__, "./000");
_run(\$cyradm, [*STDIN, *STDOUT, *STDERR], *__DATA__);
}
In other words, I just have made sure that this mysterious *__DATA__
variable is reasonably defined in every case before _run is called.
Now the command
perl -MCyrus::IMAP::Shell -e 'run("000")'
executed without any error message.
To verify that the script worked as intended, I added a few lines to it:
connect -noauthenticate localhost
auth cyrus
lm
When run as shown above, it did exactly what it was supposed to. It
asked for the password and then listed all mailboxes and their subfolders.
So now I have at least a system where I can have Term::ReadLine::Gnu
installed (and thus can have a history and command editing capabilities
in cyradm) _and_ can execute a script, although the script's filename is
hardcoded.
Probably it would be absolutely trivial for the authors of
Cyrus::IMAP::Shell to fix this issue. It would be very nice if somebody
could care about it. Perhaps it's already fixed in the newer versions? I
am still on 2.5.10.
I have no idea why the "buggy" command line / argument parsing does not
strike when Term::ReadLine::Gnu is uninstalled; I haven't grasped yet
how *__DATA__ is supposed to be assigned a reasonable value to during
the normal course of execution. I currently can only speculate that
Term::ReadLine::<default stub> does this for us, while
Term::ReadLine::Gnu doesn't.
Regards,
Binarus
More information about the Info-cyrus
mailing list