jonathanstowe / termreadkey Goto Github PK
View Code? Open in Web Editor NEWCharacter mode terminal access for Perl
Character mode terminal access for Perl
Term::ReadKey 2.36 - Change terminal modes, and perform non-blocking reads. Copyright (C) 1994-1999 Kenneth Albanowski. 2001-2016 Jonathan Stowe and others This package is dual licensed. You can either choose to license it under the original terms which were: Unlimited distribution and/or modification is allowed as long as this copyright notice remains intact. Or the standard Perl terms: This module is free software; you can redistribute it and/or modify it under the terms of the Artistic License. For details, see the full text of the license in the file "Artistic" that should have been provided with the version of perl you are using. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. This module, ReadKey, provides ioctl control for terminals and Win32 consoles so the input modes can be changed (thus allowing reads of a single character at a time), and also provides non-blocking reads of stdin, as well as several other terminal related features, including retrieval/modification of the screen size, and retrieval/modification of the control characters. Installation requires MakeMaker 3.5 or higher (MakeMaker 3.7 is included with perl 5.001, so now is a good time to upgrade if you haven't already.) To install, unpack somewhere, type "perl Makefile.PL", and then "make test". If the compilation and the tests are successful, then change to root and run "make install". As of 2.17 the interactive test has been removed as the default for the convenience of automated installers, CPAN-Testers and so on. The non interactive tests whilst confirming that the module has built correctly and has a good chance of working correctly cannot determine whether the effect as observed on the screen is correct so you might want to run: perl -Mblib example/test.pl interactive before you run 'make install'. Also from 2.17 this module has to provide its own support for compilers that can't take function prototypes as with Perl 5.8.0 this last vestige of support for non-ANSI compilers will disappear. The requirement for an ANSI C compiler has been present since Perl 5.005 so it is likely that at some point in the future this module will follow that requirement too. If you have any difficulties with older Perl's please contact the maintainer. The module has support for Win32 since version 2.10. Version 2.17 has been tested with ActivePerl build 623 and Visual Studio 6 and found to work as expected, but do not be surprised if it fails with another compiler or distribution. There are some limitations, with the ReadLine call being unavailable, and ReadKey possibly generating bad results if you are reading from multiple consoles, and key repeat is used. For Win32 users without a C compiler there is a precompiled version of this module available as a package for ActivePerl, it is probably a few versions behind the latest release but has been reported to work well. VERY IMPORTANT: In 2.00, the ReadKey/ReadLine arguments changed. Now, if you want a call that is non-blocking and returns immediately if no character is waiting, please call it with -1, instead of 1. Positive arguments now indicate a timeout, so 1 would wait a second before timing out. As older versions will accept -1, it is reccomended to change all code that uses ReadMode. The terminal mode function is controlled by the "ReadMode" function, which takes a single numeric argument, and an optional filehandle. This argument should be one of the following: 0: (Reset) Restore original settings. 1: (Cooked) Change to what is commonly the default mode, echo on, buffered, signals enabled, Xon/Xoff possibly enabled, and 8-bit mode possibly disabled. 2: (Cooked-Invisible) Same as 1, just with echo off. Nice for reading passwords. 3: (CBreak) Echo off, unbuffered, signals enabled, Xon/Xoff possibly enabled, and 8-bit mode possibly enabled. 4: (Raw) Echo off, unbuffered, signals disabled, Xon/Xoff disabled, and 8-bit mode possibly disabled. 5: (Really-Raw) Echo off, unbuffered, signals disabled, Xon/Xoff disabled, 8-bit mode enabled if parity permits, and CR to CR/LF translation turned off. If you just need to read a key at a time, then modes 3 or 4 are probably sufficient. Mode 4 is a tad more flexible, but needs a bit more work to control. If you use ReadMode 3, then you should install a SIGINT or END handler to reset the terminal (via ReadMode 0) if the user aborts the program via ^C. (For any mode, an END handler consisting of "ReadMode 0" is actually a good idea.) Non-blocking support is provided via the ReadKey and ReadLine functions. If they are passed no argument, or an argument of zero, they will act like a normal getc(STDIN) or scalar(<STDIN>). If they are passed a negative argument, then they will immediatly return undef if no input is present. If passed a positive argument, then they will wait until that time in seconds has passed before returning undef. In most situations, you will probably want to use "ReadKey -1". Note that a non-blocking ReadLine probably won't do what you expect, although it is perfectly predictable, and that the ReadMode will have to be 1 or 0 for it to make sense at all. A routine is also provided to get the current terminal size, "GetTerminalSize". This will either return a four value array containing the width and height of the screen in characters and then in pixels, or nothing ( if the OS can't return that info). SetTerminalSize allows the stored settings to be modified. Note that this does _not_ change the physical size of the screen, it will only change the size reported by GetTerminalSize, and other programs that check the terminal size in the same manner. GetControlChars returns a hash containing all of the valid control characters, such as ("INTERRUPT" => "\x3", etc.). SetControlChars takes an array (or a hash) as a parameter that should consist of similar name/value pairs and will modify the control character settings. Note that it is entirely possible that there are portability problems with the routines in ReadKey.xs. If you find any problems, including compilation failures, or control characters not supported by Set/GetControlChars, _please_ tell me about them, by mailing the maintainer at [email protected], or lastly contacting [email protected]. Any problems will get fixed if at all possible, but that's not going to happen if I don't know about them. The code is available at https://github.com/jonathanstowe/TermReadKey so as ever patches are kindly welcomed, especially for platforms such as Windows that I am unable to test on. Oh, you may also be interested in the Configure.pm module. It provides tools to make porting stuff easier -- calling the compiler, finding headers, etc. It contains documentation inside it, and you are welcome to use it in your own modules. If you make use of it, I'd be grateful for a message sent to the above address.
When installing under MSYS2/MinGW64 and using dmake, the cchars.h
file gets deleted right before it is needed by the compilation that follows:
$ cpanm --verbose Term::ReadKey
[ ...snip... ]
"C:\msys64\mingw64\bin\perl.exe" -I. -IC:\msys64\mingw64\lib\perl5\core_perl genchars.pl
Writing termio/termios section of cchars.h... Done.
Checking for sgtty...
Sgtty NOT found.
Writing sgtty section of cchars.h... Done.
"C:\msys64\mingw64\bin\perl.exe" "C:\msys64\mingw64\lib\perl5\core_perl\ExtUtils\xsubpp" -noprototypes -typemap C:\msys64\mingw64\lib\perl5\core_perl\ExtUtils\typemap ReadKey.xs > ReadKey.xsc
"C:\msys64\mingw64\bin\perl.exe" -MExtUtils::Command -e mv -- ReadKey.xsc ReadKey.c
del cchars.h
gcc -c -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing -mms-bitfields -s -O2 -DVERSION=\"2.33\" -DXS_VERSION=\"2.33\" "-IC:\msys64\mingw64\lib\perl5\core_perl\CORE" ReadKey.c
ReadKey.xs:375:20: fatal error: cchars.h: No such file or directory
compilation terminated.
dmake.exe: Error code 129, while making 'ReadKey.o'
! Installing Term::ReadKey failed. See C:\msys64\home\zaki\.cpanm\work\1467210069.17852\build.log for details. Retry with --force to force install it.
FAIL
Interim fix that prevents the deletion:
$ cpanm --verbose Term::ReadKey --build-args="RM=echo"
CC: @mohawk2
Hi Jonathan
I joined the "CPAN Pull Request Challenge" and Neil Bowers ask me to make a Pull Request on your module "Term::ReadKey".
Neil advised me to work on test suite.
Will you accept that i submit a patch in order to reorganize tests suite ?
I already fork your repository and make a branch to work on.
I tried my branch on Win32 system and Linux system and result seem clean.
...
All tests successful.
Files=2, Tests=8, 1 wallclock secs ( 0.07 usr 0.03 sys + 0.15 cusr 0.02 csys = 0.27 CPU)
Result: PASS
regards
sdeseille
SetControlChars() may internally call tcsetattr(3)
.
If a background process calls tcsetattr(3)
to the control terminal,
it gets stopped by the SIGTTOU signal.
This can be easily seen by running perl -MTerm::ReadKey -e SetControlChars
in background:
❯ perl -MTerm::ReadKey -e SetControlChars &
[1] 35956
[1] + suspended (tty output) perl -MTerm::ReadKey -e SetControlChars
❯ fg
[1] + continued perl -MTerm::ReadKey -e SetControlChars
Unable to write terminal settings in SetControlChars at -e line 1.
As a result, "make test" stops and fails if it runs as a background process:
❯ make test &
[1] 36818
"/Users/skaji/env/plenv/versions/5.30.3/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- ReadKey.bs blib/arch/auto/Term/ReadKey/ReadKey.bs 644
"/Users/skaji/env/plenv/versions/5.30.3/bin/perl" "-Iblib/arch" "-Iblib/lib" ReadKey.pm.PL ReadKey.pm
Creating ReadKey.pm
Bootstrapping the XS for blockoptions: 5
Done
Skip blib/arch/Term/ReadKey.pm (unchanged)
PERL_DL_NONLAZY=1 "/Users/skaji/env/plenv/versions/5.30.3/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_basic.t ............... ok
t/02_terminal_functions.t .. 1/7
[1] + suspended (tty output) make test
❯ fg
[1] + continued make test
t/02_terminal_functions.t .. 6/7
# Failed test 'Validate SetControlChars function'
# at t/02_terminal_functions.t line 93.
# got: 'Unable to write terminal settings in SetControlChars at t/02_terminal_functions.t line 91.
# '
# expected: ''
# Looks like you failed 1 test of 7.
t/02_terminal_functions.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/7 subtests
Test Summary Report
-------------------
t/02_terminal_functions.t (Wstat: 256 Tests: 7 Failed: 1)
Failed test: 7
Non-zero exit status: 1
Files=2, Tests=8, 2 wallclock secs ( 0.02 usr 0.01 sys + 0.07 cusr 0.01 csys = 0.11 CPU)
Result: FAIL
Failed 1/2 test programs. 1/8 subtests failed.
make: *** [test_dynamic] Error 1
I think it is nice to skip SetControlChars()
test if the test runs as a background process.
And I think we can check whether the process is in foreground or in background:
my $foreground = eval {
my $foreground_pgid = POSIX::tcgetpgrp(fileno IN);
my $current_pgid = getpgrp;
return $foreground_pgid == $current_pgid;
};
The distro I am using currently is packaging Perl 5, which permits GPL-1, however the ReadMe explicitly states Artistic License, indicating the old version of Perl which was not even GPL-compaitlbe.
Would it be possible to revise this to allow Perl 5?
This module is free software; you can redistribute it and/or modify it
under the terms of version of Perl you are using.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
Debian already seems to have assumed this and lists it as GPL-1, but this part of the license is rather ambiguous.
Thank you.
On a nearly brand new, up to date mac, Term::ReadKey won't install:
cpanm --reinstall Term::ReadKey
Gives me the following. Why would it not be able to find ReadKey.bundle? It's in /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/Term/ReadKey/ReadKey.bundle
(% perl -v
This is perl 5, version 30, subversion 2 (v5.30.2) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
)
cpanm (App::cpanminus) 1.7044 on perl 5.030002 built for darwin-thread-multi-2level
Work directory is /Users/davez/.cpanm/work/1622207785.43419
You have make /usr/bin/make
You have LWP 6.44
You have /usr/bin/tar: bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.6
You have /usr/bin/unzip
Searching Term::ReadKey () on cpanmetadb ...
--> Working on Term::ReadKey
Fetching http://www.cpan.org/authors/id/J/JS/JSTOWE/TermReadKey-2.38.tar.gz
-> OK
Unpacking TermReadKey-2.38.tar.gz
Entering TermReadKey-2.38
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.34)
Configuring TermReadKey-2.38
Running Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Term::ReadKey
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.34)
Building and testing TermReadKey-2.38
Running Mkbootstrap for ReadKey ()
chmod 644 "ReadKey.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- ReadKey.bs blib/arch/auto/Term/ReadKey/ReadKey.bs 644
"/usr/bin/perl" "/System/Library/Perl/5.30/ExtUtils/xsubpp" -noprototypes -typemap '/System/Library/Perl/5.30/ExtUtils/typemap' ReadKey.xs > ReadKey.xsc
mv ReadKey.xsc ReadKey.c
"/usr/bin/perl" genchars.pl
Writing termio/termios section of cchars.h... Done.
Checking for sgtty...
Sgtty found.
Checking sgtty...
tchars structure found.
ltchars structure found.
Checking symbols
t_brkc (EOL) found in tchars
t_dsuspc (DSUSPEND) found in ltchars
t_eofc (EOF) found in tchars
t_flushc (DISCARD) found in ltchars
t_intrc (INTERRUPT) found in tchars
t_lnextc (QUOTENEXT) found in ltchars
t_quitc (QUIT) found in tchars
t_rprntc (REPRINT) found in ltchars
t_startc (START) found in tchars
t_stopc (STOP) found in tchars
t_suspc (SUSPEND) found in ltchars
t_werasc (ERASEWORD) found in ltchars
Writing sgtty section of cchars.h... Done.
cc -c -g -pipe -fno-strict-aliasing -fstack-protector-strong -DPERL_USE_SAFE_PUTENV -Os -DVERSION=\"2.38\" -DXS_VERSION=\"2.38\" -iwithsysroot "/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE" ReadKey.c
In file included from ReadKey.xs:7:
./ppport.h:4385:10: warning: 'WIDEST_UTYPE' macro redefined [-Wmacro-redefined]
# define WIDEST_UTYPE U64TYPE
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE/handy.h:1073:12: note: previous definition is here
# define WIDEST_UTYPE U64
^
1 warning generated.
rm -f blib/arch/auto/Term/ReadKey/ReadKey.bundle
cc -bundle -undefined dynamic_lookup -fstack-protector-strong ReadKey.o -o blib/arch/auto/Term/ReadKey/ReadKey.bundle \
\
chmod 755 blib/arch/auto/Term/ReadKey/ReadKey.bundle
"/usr/bin/perl" "-Iblib/arch" "-Iblib/lib" ReadKey.pm.PL ReadKey.pm
Can't load 'blib/arch/auto/Term/ReadKey/ReadKey.bundle' for module Term::ReadKey: dlopen(blib/arch/auto/Term/ReadKey/ReadKey.bundle, 0x0001): open("", O_RDONLY) failed with errno=2 at /System/Library/Perl/5.30/darwin-thread-multi-2level/DynaLoader.pm line 197.
^@ at /System/Library/Perl/5.30/darwin-thread-multi-2level/DynaLoader.pm line 95.
DynaLoader::croak("Can't load 'blib/arch/auto/Term/ReadKey/ReadKey.bundle' for m"...) called at /System/Library/Perl/5.30/darwin-thread-multi-2level/DynaLoader.pm line 197
DynaLoader::bootstrap("Term::ReadKey") called at ReadKey.pm.PL line 515
Creating ReadKey.pm
Bootstrapping the XS for blockoptions: make: *** [ReadKey.pm] Error 255
-> FAIL Installing Term::ReadKey failed. See /Users/davez/.cpanm/work/1622207785.43419/build.log for details. Retry with --force to force install it.
However, manually doing:
davez@DAVIDs-MBP TermReadKey-2.38 % cc -bundle -undefined dynamic_lookup -fstack-protector-strong ReadKey.o -o blib/arch/auto/Term/ReadKey/ReadKey.bundle
davez@DAVIDs-MBP TermReadKey-2.38 % ls -l blib/arch/auto/Term/ReadKey/ReadKey.bundle
-rwxr-xr-x 1 davez staff 55072 28 May 14:27 blib/arch/auto/Term/ReadKey/ReadKey.bundle
davez@DAVIDs-MBP TermReadKey-2.38 % "/usr/bin/perl" "-Iblib/arch" "-Iblib/lib" ReadKey.pm.PL ReadKey.pm
Creating ReadKey.pm
Can't load 'blib/arch/auto/Term/ReadKey/ReadKey.bundle' for module Term::ReadKey: dlopen(blib/arch/auto/Term/ReadKey/ReadKey.bundle, 0x0001): open("", O_RDONLY) failed with errno=2 at /System/Library/Perl/5.30/darwin-thread-multi-2level/DynaLoader.pm line 197.
at /System/Library/Perl/5.30/darwin-thread-multi-2level/DynaLoader.pm line 95.
DynaLoader::croak("Can't load 'blib/arch/auto/Term/ReadKey/ReadKey.bundle' for m"...) called at /System/Library/Perl/5.30/darwin-thread-multi-2level/DynaLoader.pm line 197
DynaLoader::bootstrap("Term::ReadKey") called at ReadKey.pm.PL line 515
Bootstrapping the XS for blockoptions: %
davez@DAVIDs-MBP TermReadKey-2.38 % find . -name \*.bundle
./blib/arch/auto/Term/ReadKey/ReadKey.bundle
But ReadKey.bundle is there! I wonder if I should just brew an old perl to match the one I'm using.
The minimum version of EUMM required hasn't been raised for a very long time, I'm tempted to go with 6.42 as that is what shipped with 5.10.0
As reported by @pghmcfc on #21 the way the Makefile is constructed and the way that the dynamic part of the module is used in the creation of the ReadKey.pm does not play nicely with a parallel build:
$ make -j4
"/usr/bin/perl" genchars.pl
Running Mkbootstrap for ReadKey ()
"/usr/bin/perl" "-Iblib/arch" "-Iblib/lib" ReadKey_pm.PL ReadKey.pm
chmod 644 "ReadKey.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- ReadKey.bs blib/arch/auto/Term/ReadKey/ReadKey.bs 644
Can't locate loadable object for module Term::ReadKey in @INC (@INC contains: blib/arch blib/lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/lib64/perl5/DynaLoader.pm line 95.
DynaLoader::croak("Can't locate loadable object for module Term::ReadKey in \@INC"...) called at /usr/lib64/perl5/DynaLoader.pm line 159
DynaLoader::bootstrap("Term::ReadKey") called at ReadKey_pm.PL line 507
Creating ReadKey.pm
Bootstrapping the XS for blockoptions: make: *** [Makefile:534: ReadKey.pm] Error 255
make: *** Waiting for unfinished jobs....
Writing termio/termios section of cchars.h... Done.
Checking for sgtty...
Sgtty NOT found.
Writing sgtty section of cchars.h... Done.
This will require fixing the Makefile generated by EUMM to make the 'dynamic' target a dependency of the ReadKey.pm generation.
This is somewhat complicated by the fact I can't reproduce on my stock perl (though I can with a v5.24.0 in perlbrew.)
Trying to install Term::ReadKey under cygwin, the process hangs and package can not be installed.
Trying to force install
won't help as the tests will still be run and process still hangs
Given the original wording was:
Unlimited distribution and/or modification is allowed as long as this
copyright notice remains intact.
This really sounds more like public domain, except that it keeps a copyright. MIT license really sounds the closest, as this allows use in anything, as long as the copyright is included:
If you give ReadKey an argument between 0 and 1, it hangs forever.
This was working fine with StrawberryPerl 5.20.1.1.
Code:
use 5.020;
use warnings;
use strict;
use Term::ReadKey;
warn "Version: $Term::ReadKey::VERSION \n";
my $x = ReadKey(1e-5);
warn "x: $x";
You can reproduce this easily, even without a windows installation, using the following Appveyor build script: (See a recent blog post of eserte)
install:
- choco install strawberryperl
- path C:\strawberry\perl\bin;C:\strawberry\perl\site\bin;C:\strawberry\c\bin;%PATH%
- perl -V
build_script:
- perl term-readkey.pl
See https://ci.appveyor.com/project/amba/term-readkey-windows/build/1.0.3 for the full build log.
Wed Sep 04 03:48:20 2019: Request 130445 was acted upon.
Transaction: Ticket created by KUERBIS
Queue: TermReadKey
Subject: Win32 term width
Broken in: (no value)
Severity: (no value)
Owner: Nobody
Requestors: [email protected]
Status: new
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=130445 >
ReadKey.xs - lines 505,506:
if (retheight)
*retheight = info.srWindow.Bottom - info.srWindow.Top;
Should this be "Bottom + 1 - Top" instead of "Bottom - Top"?
I'm working on a program that does a call to GetTerminalSize() in Term::ReadKey. Usually the output goes to the terminal, but sometimes it may be redirected. Regardless of the case, I want to grab my terminal dimensions, including the pixel sizes. This is easily done by just looking at /dev/tty instead of STDOUT. However, Term::ReadKey doesn't work the way I would expect when trying to pass a filehandle to GetTerminalSize. From the documentation, I would think I could do this:
use Term::ReadKey;
open(TTY, "/dev/tty");
my($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize(TTY);
close(TTY);
But it doesn't work. Looking at the module, it's expecting the filehandle to be the 2nd argument to GetTerminalSize:
my ($file) = normalizehandle( ( @_ > 1 ? $_[1] : \*STDOUT ) );
Shouldn't this be:
my ($file) = normalizehandle( ( @_ > 0 ? $_[0] : \*STDOUT ) );
In order to get my program to work, I had to just pass a value (which looks to be ignored) before I pass the filehandle:
open(TTY, "/dev/tty");
my($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize("some junk", TTY);
close(TTY);
Because there is no executable package statement in the ReadKey_pm.PL
this is not being indexed so the new version isn't being picked up by the search.cpan or metacpan,
This probably can be remedied by putting a package Term::ReadKey
in the script somewhere.
On this system:
I am seeing ReadKey(-1) block until a key is pressed. Ideas? Thank you.
use strict;
use warnings;
use Term::ReadKey;
$|=1;
print("\nStarting ReadKey blocking test. Do not hit a key...\n");
testReadKey(1); # ReadKey times out and returns undef as expected
testReadKey(-1); # ReadKey blocks until a key is pressed
print("\nTest complete\n");
sub testReadKey {
my $readKeyArg = shift;
print("\nTesting \$key=ReadKey($readKeyArg) : ");
ReadMode(4);
my $key = ReadKey($readKeyArg);
ReadMode(0);
if(not defined $key) {
print("\$key is undefined, test passed\n");
}
else {
print("\$key is defined, test failed\n");
}
}
Morning all,
Looks like yesterday's update may have broke something...
cpanm (App::cpanminus) 1.7034 on perl 5.010001 built for x86_64-linux-thread-multi
Work directory is /root/.cpanm/work/1433511216.30684
You have make /usr/bin/make
You have /usr/bin/wget
You have /bin/tar: tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching Term::ReadKey () on cpanmetadb ...
--> Working on Term::ReadKey
Fetching http://www.cpan.org/authors/id/J/JS/JSTOWE/TermReadKey-2.33.tar.gz
-> OK
Unpacking TermReadKey-2.33.tar.gz
Entering TermReadKey-2.33
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.04)
Configuring TermReadKey-2.33
Running Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Term::ReadKey
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.04)
Building and testing TermReadKey-2.33
cp ReadKey.pm blib/lib/Term/ReadKey.pm
AutoSplitting blib/lib/Term/ReadKey.pm (blib/lib/auto/Term/ReadKey)
Running Mkbootstrap for Term::ReadKey ()
chmod 644 "ReadKey.bs"
"/usr/bin/perl" -I. -I/usr/share/perl5 genchars.pl
Writing termio/termios section of cchars.h... Done.
Checking for sgtty...
Sgtty NOT found.
Writing sgtty section of cchars.h... Done.
"/usr/bin/perl" "/usr/share/perl5/ExtUtils/xsubpp" -noprototypes -typemap "/usr/share/perl5/ExtUtils/typemap" ReadKey.xs > ReadKey.xsc && mv ReadKey.xsc ReadKey.c
gcc -c -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION=\"2.33\" -DXS_VERSION=\"2.33\" -fPIC "-I/usr/lib64/perl5/CORE" ReadKey.c
rm -f blib/arch/auto/Term/ReadKey/ReadKey.so
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic ReadKey.o -o blib/arch/auto/Term/ReadKey/ReadKey.so \
\
chmod 755 blib/arch/auto/Term/ReadKey/ReadKey.so
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- ReadKey.bs blib/arch/auto/Term/ReadKey/ReadKey.bs 644
Manifying 1 pod document
Running Mkbootstrap for Term::ReadKey ()
chmod 644 "ReadKey.bs"
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_basic.t ............... ok
# Looks like you planned 7 tests but ran 1.
t/02_terminal_functions.t ..
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 6/7 subtests
(less 1 skipped subtest: 0 okay)
Test Summary Report
-------------------
t/02_terminal_functions.t (Wstat: 65280 Tests: 1 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 7 tests but ran 1.
Files=2, Tests=2, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.03 cusr 0.00 csys = 0.06 CPU)
Result: FAIL
Failed 1/2 test programs. 0/2 subtests failed.
make: *** [test_dynamic] Error 255
-> FAIL Installing Term::ReadKey failed. See /root/.cpanm/work/1433511216.30684/build.log for details. Retry with --force to force install it.
I am no perl guy but could this have something to do with the unit tests? Installing this package is part of our deployment scripts for new environments, so we download and install it multiple times per day. This morning I hit this error and I think there was an update last night. I am trying to downgrade now.
Thanks!
Hello and thanks for your work,
the win32 version of the module seems to not check for undefined values in the ReadKey sub. This should be around line 678 (line 476 of the on the fly created module).
So I suppose that the line:
if ($_[0] || $CurrentMode >= 3)
should be something like:
if ( defined $_[0] || $CurrentMode >= 3)
See also this perlmonks thread
Thanks for reading
L*
Could you please confirm that Term::ReadKey is or is not thread-safe?
I experience quite a lot of crashes of Term::ReadKey 2.33 in a forking environment under Windows.
Starting in 2.37, the dist metadata says that META.yml
is the file that provides the Term::ReadKey
package. This appears to be deliberately injected by the ADD_META
in Makefile.PL
. This throws off Module::Metadata
(used by Metacpan and Pinto) which expect the file to be something that looks like source code (usually either a .pm or .PL file). Can you help @mschout and myself understand why it is being done this way. See also thaljef/Pinto#241
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.