maxima命令行v5.43的行为与v5.41不同 [英] maxima command line v5.43 is behaving differently than v5.41

查看:189
本文介绍了maxima命令行v5.43的行为与v5.41不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将maxima从5.41.0升级到5.43.2,这破坏了我的代码.我找不到在两个版本中都可以以相同方式工作的解决方案.这是我正在执行的简化命令行示例:

I recently upgraded maxima from 5.41.0 to 5.43.2 and it broke my code. I could not find a solution that works in both versions the same way. Here is the simplified command line example I am executing:

在5.41.0版中:

user@system:~> maxima -version
Maxima 5.41.0
user@system:~>  maxima --very-quiet -r 'display2d: false$ leftjust: true$ ratprint: false$ dispflag: false$      is(equal((a+b)**2 = (a**2 + b**2 + 2*a*b), (a+b)*(a+b) = (a**2 + b**2 + 2*a*b))); ttyoff:true$ quit()$'
true
user@system:~>

在5.43.2版中:

user@system:~> maxima -version
Maxima 5.43.2
user@system:~>  maxima --very-quiet -r 'display2d: false$ leftjust: true$ ratprint: false$ dispflag: false$      is(equal((a+b)**2 = (a**2 + b**2 + 2*a*b), (a+b)*(a+b) = (a**2 + b**2 + 2*a*b))); ttyoff:true$ quit()$'
display2d:false
leftjust:true
ratprint:false
dispflag:false
is(equal((a+b)^2 = a^2+b^2+2*a*b,(a+b)*(a+b) = a^2+b^2+2*a*b))
true
ttyoff:true

有两个问题(1)v5.43.2中的命令在完成后没有退出maxima以返回到shell命令提示符,而在v5.41.0中,它退出了maxima并返回到shell命令提示符. (2)因此,我添加了quit()$,但命令的回声不会被终止符$抑制.

There are two issues (1) command in v5.43.2 is not quitting maxima after completion to come back to the shell command prompt, where as in v5.41.0, it quits maxima and comes back to the shell command prompt. (2) so, I added quit()$ but the echo of commands is not suppressed with terminator $.

我试图阅读文档以查找有关此的任何信息,但没有发现任何明显的内容.我的目标是安静地执行传入的命令并仅打印(最后)命令的输出.真的很感激任何帮助.

I tried to read the docs to find any info on this, but did not see anything obvious. My objective to execute the passed in command quietly and print only the output of the (last) command. Any help in this matter is really appreciated.

推荐答案

在查看Git日志时,似乎在提交fa97979中更改了--run-string(即,-r)的行为.因此,就目前的价值而言,当前的行为被认为是正确的.也就是说,要解决(1),您可以尝试使用--batch-string选项而不是--run-string.

On reviewing the Git log, it appears the behavior of --run-string (i.e., -r) was changed in commit fa97979. So the current behavior is considered correct, for what it's worth. That said, to address (1), you can try the --batch-string option instead of --run-string.

关于(2),尽管美元符号抑制了输出,但输入仍在回显,这就是您所看到的.我也不知道抑制输入的方法.在这一点上,我可以看到几种可能的方法.

About (2), although dollar sign suppresses the output, the input is still echoed, and that's what you're seeing. I don't know a way to suppress the input also. At this point I can see a couple of possible approaches.

一种是省略--very-quiet,以便获得输入和输出标签.然后,对输出标签进行grep输出,或者更精确地说,对输出标签进行grep输出,后跟零个或多个不带标签的行(捕获多行输出).

One is to omit --very-quiet, so that you get input and output labels. Then grep the output for output labels, or maybe more precisely, grep for an output label following by zero or more lines which do not have a label (to capture multi-line output).

另一种方法是只忘记标签,然后说with_stdout("/tmp/foo.out", print(...)),在其中打印与以后处理有关的内容,然后转储文件/tmp/foo.out或以后调用的任何东西.这有点笨拙,但可能更容易在输出文件中准确获得所需的内容.

The other approach is to just forget about labels and say with_stdout("/tmp/foo.out", print(...)) where you print the stuff that's relevant to later processing, and then just dump out the file /tmp/foo.out or whatever it's called afterwards. This is a little clumsier, but probably easier to get exactly what you want in the output file.

有时我会创建看起来像bash的脚本

I sometimes create bash scripts which look like

cat << EOF > /tmp/foo.mac
someflag: true;
somevar: 1234;
foo: expand (something (something));
EOF
maxima --batch=/tmp/foo.mac

因此,bash脚本创建了Maxima程序,然后Maxima执行了该程序.如果我想在Maxima程序中使用bash变量(例如文件名或其他名称),这将特别有用,例如

so the bash script creates the Maxima program and then Maxima executes it. That's especially useful if I want to use bash variables (e.g. filenames or something) in the Maxima program, e.g.

f=$1-$2.csv  # something I just made up
cat << EOF > /tmp/foo.mac
myinput: openr ("$f");
/* etc etc */
EOF

这篇关于maxima命令行v5.43的行为与v5.41不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆