Created
October 3, 2012 16:01
-
-
Save moritz/3827804 to your computer and use it in GitHub Desktop.
Basic readline wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
module Readline; | |
use NativeCall; | |
my constant read_lib = 'libreadline.so.5'; | |
my constant hist_lib = 'libhistory.so.5'; | |
sub readline (Str) returns Str is native(read_lib) { * }; | |
sub add_history(Str) is native(hist_lib) { * }; | |
sub read-line(Str $prompt) returns Str is export { | |
my $input = readline($prompt); | |
add_history($input); | |
return $input; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment