smalltalk – 使用Squeak从shell

我可以启动Squeak作为REPL(没有GUI),在哪里可以输入和评估Smalltalk表达式?我知道认图像不允许这样。是否有任何文档如何构建可以从命令行shell访问的最小映像?
这里是(hackish)解决方案:
首先,您需要OSProcess,因此在Workspace中运行:
Gofer new squeaksource:'OSProcess'; package:'OSProcess';load.

接下来,将其放在文件repl.st中:

OSProcess thisOSProcess stdOut 
  nextPutAll: 'Welcome to the simple Smalltalk REPL'; 
  nextPut: Character lf; nextPut: $>; flush.
[ |input|
  [ input := OSProcess readFromStdIn.
    input size > 0 ifTrue: [
      OSProcess thisOSProcess stdOut 
        nextPutAll: ((Compiler evaluate: input) asstring; 
        nextPut: Character lf; nextPut: $>; flush 
    ]
  ] repeat.
]forkAt: (Processor userBackgroundPriority)

最后,运行这个命令:

squeak -headless path/to/squeak.image /absolute/path/to/repl.st

你现在可以有一个Smalltalk REPL的乐趣。不要忘记键入命令:

Smalltalk snapshot:true andQuit:true

如果要保存您的更改。

现在,对这个解决方案的解释:
OSProcess是一个包,它允许运行其他进程,从stdin读取,并写入stdout和stderr。您可以使用OSProcess thisOSProcess(当前进程,也称为squeak)访问stdout AttachableFileStream。

接下来,在userBackgroundPriority(运行其他进程)上运行无限循环。在这个无限循环中,使用Compiler evaluate:执行输入。

你运行在一个无头的图像的脚本。

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...