Looking into 'sb-ext::run-program' docs shows that 't' means
inheriting standard input, output and error output from current
process, which at least in some cases seem to be right thing.
The current process is FRICASsys. So it goes to the stdout and stderr of
whatever FRICASsys gets. Do I understand this correctly?
At least that would be confirmed by the fact that when I start fricas as
follows
https://github.com/fricas/jfricas/blob/master/jfricas/fricaskernel.py#L518
pid = Popen(['gnome-terminal', '--title=jfricas', '--'] +
['fricas','-nosman','-eval',prereq,'-eval',start])
instead of the default
pid = Popen(['fricas','-eval',prereq,'-eval',start]) (*)
then typing ")sys ls" in a jfricas notebook cell outputs into the
gnome-terminal.
However, this is, of course not what I want. In particular, when a user
types ")sys pwd" he wouldn't get that information at all (with (*)),
because then the process is whatever Jupyter does internally. It does
certainly NOT appear on the console from where I start "jupyter notebook".
This problem with stdout of )sys commands is one of the reasons why we
added such an option with gnome-terminal into the fricaskernel.py.
You say that you want to catch error output. But what errors?
(1) -> )sys foo
/bin/sh: 1: foo: not found
That is visible in a ordinary fricas session but not in jfricas unless I
start OBEY with the ":error *standard-output" (or *error-output*) option.
A little grepping of sources shows that currently one main use case
for OBEY is starting external editor, where inherited file
descriptors seem to be correct (and in jFriCAS you probably do not
want to support this or offer replacement compatible with Web
interface).
Hmmm... maybe I should even disallow ")edit". Oh... no need... even in
the console fricas it says.
(1) -> )edit "foo.input"
Warning: environment variable FRICASEDITOR not set.
Launching 'more' in an 'xterm'.
Press space to continue, 'q' to quit.
)edit is nowadays only necessary for people working completely in
ASCII-mode and do not now about Ctrl-Z to stop a process, do something
else (like editing) and come back into the fricas console. That pretty
much sounds like ")edit" can be removed, because I do not see a use case
anymore.
Anyway, with
(sb-ext::process-exit-code
(sb-ext::run-program "/bin/sh"
(list "-c" S) :input t :output *standard-output*
:error *error-output*))
From "FRICASEDITOR=emacs jfricas" I can perfectly fine issue the command
)edit "foo.input" in a jfricas notebook cell.
Other use case are calls to few system commands where errors are
_not_ expected. If some unexpected error pops up it is debatable
where message should go, but resonable convention is that those
errors should go to FRICASsys standard error.
Not in the case of jfricas. The jupyter notebook is the only visible
form of communication. I have no control over how fricaskernel.py (and
therefore FRICASsys) is started. No idea what jupyter does with stdout
and stderr and from where I could fetch that output.
In particular, I not sure what you are doing with OBEY that you need
to catch standard output?
I want ")sys pwd" to show me something. We have included ")!
some-shell-command" in jfricas, just because we didn't know how to catch
)sys output", but ")! pwd" and ")sys pwd" do not give the same result,
because ")!" always starts a new shell. Maybe with now having a way that
)sys can output something, ")!" should probably go away or be synonymous
to )sys.
To put it differently, ATM you can launch text editor or a shell via
')system' command and it almost works (there is some breakage due to
clef/rlwrap interfering, AFAICS without sman it works fine). This
is not very important use case, but it is nice to keep what works
working. OTOH in jFriCAS I would _not_ expect current ')system' to
work, at least not without some alternative implementation.
With the modified OBEY, it works fine at least for what I have seen so
far. I do not claim that I have tested it well enough, but I am happy
that ")sys pwd" works. I do not want to do fancy stuff and when
eventually jFriCAS is mature enough and we can offer a server and a
webinterface to access fricas from the internet, we probably want to
turn off )sys and other dangerous things completely. But that shouldn't
concern us now in the local use case.
For jfricas it wouldn't probably matter since I anyway set
*error-output* to *standard-output*.
In fact, browsing through the FriCAS code, it seems that
*error-output* is only used in the lisp optimizer.
Well, currently when we generate Lisp code Lisp '*standard-output*'
is redirected to file. But we definitely do not want error messages
going to '*standard-output*': some messages are just warning, but
if emmited to file would make it syntactiacally incorrect.
Hmmm... here the question is when does the optimizer jump in? Only at
the time when fricas is build or also when a user defines a function and
that function is compiled at its first use? Only the second case would
be problematic. For the first we could let OBEY be as it is now.
User normally does not look at generated file so error messages
emmited to file are effectively lost.
In the beginning jfricas collected output from different streams in
different stores. But that was a problem with the order in which jfricas
would show the total output, because a cell can potentially contain
multiline input like
foo1
)set output algebra off
)set output tex on
foo2
)sys pwd
)set output algebra on
)set output tex off
foo3
I wouldn't want to see the output of foo1 and foo3 before the output of
foo2 in tex. So everything in jfricas goes to *standard-output*, but
comes with begin and end markers that tell fricaskernel.py in which
format it should be presented. Maybe not perfect, but works.
BTW: As I wrote Saturn (Texexplorer) had notebook interface. While
code supporting Saturn is removed now you can look at past versions
to see how they handled tricky problems. In particular
i-output.boot was modified to behave as needed by Saturn. IIRC this
included TeX output of types and handling of line numbers.
Tex output is completely uninteresting for jfricas. We have
FormatMathJax for that.
BTW2: My impression is that in Saturn "unexpected" error messages
went to AXIOMsys console.
The question is what is the "AXIOMsys console"? Other question is when I
type ")sys foo" and get an error message like "/bin/sh: 1: foo: not
found", then I wouldn't count that as an error of the ")sys" command,
but rather a valid output of what I asked for. If ")sys" itself or any
other comman finds weird behaviour and wants to report (to FriCAS
developers), then it is questionable where this should go. But I would
even argue that it should be visible to the user with clear message that
he/she should report to the fricas-devel list.
Ralf
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/57fad1aa-9365-69ed-c13a-ca5dd096bc37%40hemmecke.org.