dear julia experts—Is it possible to to invoke julia in batch but still receive the output as if the session was interactive REPL? maybe this could be done by tricking the session into thinking it is interactive, even though stdin comes from a file. for example, if my script ‘a.jl’ contains
I want to see (or construct) an output ‘a.log’ that looks like
I am thinking of using the Unix
expect command, but this one has its own drawbacks, not the least of which is that julia prompts in boldface and I do not know how to turn this off. (
julia --color=off does not turn off boldfacing afaics.)
(the use for this feature is to write tests for interactive sessions.)
$ echo 1 + 2 | julia -i
hi stefan—I had written a response why
julia -i < a.jl does not work, but then decided to try, on the spur of the moment,
cat a.jl | julia -i. The latter works, the former does not. I always thought the two were completely identical and indistinguishable from the perspective of the receiving program. (how does julia know the difference??) thanks. solves my problem.
almost. the trailing semi-colon that suppresses output seems to be ignored. can this be fixed?
$ echo "rand(2);" | julia -i
one way to avoid this is to replace any ‘;’ ending statements with
$ echo "rand(2);print()" | julia -i
They’re distinguishable: pipe versus file. However they should both work so please do file an issue.
hi stefan—is it a buglet or intended behavior that a trailing semicolon does not suppress result output in “batch -i”?
Not sure. Might as well mention it in the same issue.