Skip to content

Instantly share code, notes, and snippets.

@moritz
Created October 3, 2012 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moritz/3827804 to your computer and use it in GitHub Desktop.
Save moritz/3827804 to your computer and use it in GitHub Desktop.
Basic readline wrapper
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