kaluma-project / kaluma

A tiny JavaScript runtime for RP2040 (Raspberry Pi Pico)
https://kalumajs.org
Apache License 2.0
648 stars 38 forks source link

[BUG] Soft-reset adds module commands each time #576

Closed shreeve closed 1 year ago

shreeve commented 1 year ago

When typing .help after first launching the REPL, we see:

> .help
.help   Print this help message
.hi Print welcome message
.echo   Echo on/off
.reset  Soft reset
.flash  Commands for flash
.load   Load code from flash
.mem    Heap memory status
.gc Perform garbage collection
.ls List files
.pwd    Print current directory
.cd Change current directory
.mkdir  Create directory
.rm Remove file or directory
.cat    Print the content of file

But, each time we do a soft reset, any module commands (not the default REPL commands) get added again, like this:

> .help
.help   Print this help message
.hi Print welcome message
.echo   Echo on/off
.reset  Soft reset
.flash  Commands for flash
.load   Load code from flash
.mem    Heap memory status
.gc Perform garbage collection
.ls List files
.pwd    Print current directory
.cd Change current directory
.mkdir  Create directory
.rm Remove file or directory
.cat    Print the content of file
.ls List files
.pwd    Print current directory
.cd Change current directory
.mkdir  Create directory
.rm Remove file or directory
.cat    Print the content of file

For each reset, we get the .ls through .cat commands added another time.

shreeve commented 1 year ago

I've got a fix for this and will submit a PR now