Skip to content

Commit

Permalink
Fix R#3476 and make RAKUDO_HIST work
Browse files Browse the repository at this point in the history
- add check for old history file
- if old exists, and new one doesn't, move the history file
- use slurp/spurt for moving, rather than rename just in case the
  new directory happens to be on a different device.
- fix check for RAKUDO_HIST, it was using the always non-existing
  $*ENV rather than %*ENV
  • Loading branch information
lizmat committed Feb 12, 2020
1 parent 8876e03 commit c5c98de
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core.c/REPL.pm6
Expand Up @@ -407,9 +407,19 @@ do {

method history-file(--> Str:D) {
without $!history-file {
$!history-file = $*ENV<RAKUDO_HIST>
?? $*ENV<RAKUDO_HIST>.IO
!! ($*HOME || $*TMPDIR).add('.perl6/rakudo-history');
if %*ENV<RAKUDO_HIST> -> $history-file {
$!history-file = $history-file;
}
else {
my $dir := $*HOME || $*TMPDIR;
my $old := $dir.add('.perl6/rakudo-history');
my $new := $dir.add('.raku/rakudo-history');
if $old.e && !$new.e { # migrate old hist to new location
$new.spurt($old.slurp);
$old.unlink;
}
$!history-file = $new;
}

without mkdir $!history-file.parent {
note "I ran into a problem trying to set up history: {.exception.message}";
Expand Down

0 comments on commit c5c98de

Please sign in to comment.