Add fish shell
If bash and pwsh can do it, then fish shell should also be able to do it :)
https://github.com/fish-shell/fish-shell
It's certainly possible but I notice one major functionality gap in fish is the lack associative arrays (dictionaries): https://github.com/fish-shell/fish-shell/issues/390
One of the most complicated aspects of the bash implementation is that associative arrays values are just scalars (they can't be arrays or associative arrays) so the implementation has to do a lot of indirection. But at least it has associative arrays in some form.
But if somebody wants to tackle it and they submit a fully functional implementation that follows the mal incremental structure, I'll be happy to consider merging it 😄
I wanted to give it a try but now I'm stuck on the very first step. Even this simple program can't pass the tests for step0 on my machine.
while true
read --function --line --prompt-str 'user> ' source
echo $source
end
Does anyone know what am I doing wrong?
@aShabat What error did you get?
Here's the output of running make "test^fish^step0"
make -C impls/fish step0_repl.fish
make[1]: Entering directory '/home/anton/projects/mal/impls/fish'
make[1]: Nothing to be done for 'step0_repl.fish'.
make[1]: Leaving directory '/home/anton/projects/mal/impls/fish'
(call STEP_TEST_FILES,fish,step0): impls/tests/step0_repl.mal
----------------------------------------------
Testing test^fish^step0; step file: impls/fish/step0_repl.fish, test file: tests/step0_repl.mal
Running: env STEP=step0_repl MAL_IMPL=js ../../runtest.py --deferrable --optional ../tests/step0_repl.mal -- ../fish/run
Testing basic string
TEST (line 3): 'abcABC123' -> '.*\nabcABC123' -> TIMED OUT
Testing string containing spaces
Testing string containing symbols
Test long string
Non alphanumeric characters
------- Optional Functionality --------------
------- (Not needed for self-hosting) -------
Non alphanumeric characters
FAILURES:
TIMED OUT TEST (line 3): 'abcABC123' -> '.*\nabcABC123':
Expected : '.*\nabcABC123'
Got : ''
TEST RESULTS (for ../tests/step0_repl.mal):
0: soft failing tests
1: failing tests
0: passing tests
1: executed tests
24: total tests in the file (23 skipped)
That indicates that the test harness is waiting for the echo'd output and never got it.
I understand, but when I ran the code myself it works as expected, immediately printing what I wrote.
I don't understand Makefile good enough to figure out how exactly does it run tests and why do they behave how they do
The makefile is running this (from the impls/fish directory):
env STEP=step0_repl MAL_IMPL=js ../../runtest.py --deferrable --optional ../tests/step0_repl.mal -- ../fish/run
Some of that isn't relevant to what you are doing so you can simplify it to this:
STEP=step0_repl ../../runtest.py ../tests/step0_repl.mal -- ../fish/run
The test harness (runtest.py) is running ../fish/run in a pty (interactive) context and telling it to run step0_repl (the STEP environment variable). The harness loads the test file (../tests/step0_repl.mal), and sends the tests from the file to the running interpreter one at a time (waiting for a user> prompt between each test). I suspect that the fish shell is doing something odd in terms of detecting what type of context it is running in (interactive, raw/cooked, stdin, pty, etc) and instead of behaving like an interactive interpreter it is running in non-interactive/scripting mode and not echo'ing the input (and maybe not printing the prompt either). This is a problem we've had with other languages where they try and be tricky about detecting their shell/interactivity context and so the test harness isn't able to test them. There might be environment variables or command line options that you could add to fish/run to get the shell to behave the way the harness expects.
Yes! Thank you for detailed explanation. I added flag to run fish in interactive mode and now it works