uiua-lang / uiua

A stack-based array programming language
https://www.uiua.org
MIT License
1.51k stars 106 forks source link

Cannot open read-only files #485

Closed Defelo closed 4 months ago

Defelo commented 4 months ago

Since commit 3ea819db1c3c999f27f53b6330819d0c40c04423 it is no longer possible to open and read from files that are not writable, because both &fo and &fras always seem to attempt to open the file in read-write mode.

When trying to read a read-only file (e.g. mode 444), I get a permission denied error:

↪ &fras "test"
Error: Permission denied (os error 13) test
  at 1:1
1 | &fras "test"
    ─────

And when trying to read a file that in theory is writable (e.g. mode 644), but is located on a read-only filesystem, I get this error:

↪ &fras "test"
Error: Read-only file system (os error 30) test
  at 1:1
1 | &fras "test"
    ─────

Another problem I encountered with the aforementioned commit is that it is no longer possible to read from stdin using &fras. For example, echo test | uiua run test.ua (where test.ua uses &fras "/dev/stdin" to process stdin) worked fine before this commit, but now the program always gets stuck.

kaikalii commented 4 months ago

This is addressed in 65800088b96e4. I tested it on a Windows readonly file, but I haven't tested it on Linux. Please let me know if it is fixed.

Defelo commented 4 months ago

Yes, thanks a lot, &fras on read-only files is fixed now. The second problem I described still persists, but I think I can just use &ru @\0 0 instead which works fine, so I will close this issue.