<div dir="ltr"><div dir="ltr">Hi Christoph,</div><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div id="m_-41324370072627956gmail-m_1502669873579509278divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr"><p><br>unfortunately, I cannot reproduce your command - in my shell, the VM only outputs that "<span style="font-size:12pt">pthread_setschedparam failed: Operation not permitted. </span><span style="font-size:12pt">This VM uses a separate heartbeat thread ..."
 warning and then hangs on, even if my script ends by calling Smalltalk quitPrimitive.</span></p></div></div></blockquote><div>I believe it has nothing to do with my command.  Even if you try to just run </div><div><br></div><div>   squeak -version</div><div><br></div><div>in that environment, I think you'll get the same error.  There are two flavors of the Linux VM, you're using the version of the VM that's a little better, but requires you to install a file into your security limits that allows it to work.</div><div><br></div><div>Create a text file called "squeak.conf" with these contents (between the horizontal lines):</div><div><br></div><div>*       hard    rtprio  2<br></div>*       soft    rtprio  2<div><br></div><div>Copy that file to </div><div><br></div><div>  /etc/security/limits.d/squeak.conf</div><div><br></div><div>and you should now be able to launch the Squeak VM, and my command will work, even with FileExistsException.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div id="m_-41324370072627956gmail-m_1502669873579509278divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p><span style="font-size:12pt">---</span><br></p>
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt">However, I made the example with #writePNGfileNamed: because if the file exists, it does not raise an Error or some other unhandled exception, but a FileExistsException which, by default, opens a UIManager.</span><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)"> </span></p></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div id="m_-41324370072627956gmail-m_1502669873579509278divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr"><p><span style="font-size:12pt">This happens just
 so often in Squeak that I would like to implement a CommandLIneUIManager for this case.</span></p></div></div></blockquote><div>You could consider refactoring writePNGfileNamed: and other places to dispatch to an interim-level method that takes the actual Stream you want to write to, that way, instead of having to worry about catching exceptions, you can simply create your own FileStream (with UI's, or not) and use the lower-level method.</div><div><br></div><div>Even though I think it could be improved, asking for a file via UI is a real use-case for Squeak, and supporting that use-case in a way that allows overriding via exception handling is a good idea.</div><div><br></div><div>Best,</div><div>  Chris</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div id="m_-41324370072627956gmail-m_1502669873579509278divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr"><p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt">And of course, you might even combine this with the SqueakShell to avoid this inconsistent situation:</span></p>
<p><span style="font-size:12pt"><img size="287990" id="m_-41324370072627956gmail-m_1502669873579509278img672111" style="max-width:99.9%" src="cid:16e43c9dd37f456b1e51"><br>
</span></p>
<p><br>
</p>
<p>If I find some time, I will be happy to upload some proposal into the inbox :)</p>
<p><br>
</p>
<p>@Fabio: Yes, separately handling a ProvideAnswerNotification in the SCITestRunner sounds good. However, I would first focus on solving that problem for all CLI applications, but I will keep it in mind :)</p>
<p><br>
</p>
<p>Best,</p>
<p>Christoph</p>
<div id="m_-41324370072627956gmail-m_1502669873579509278Signature">
<div name="divtagdefaultwrapper">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="m_-41324370072627956gmail-m_1502669873579509278divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> Squeak-dev <<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org" target="_blank">squeak-dev-bounces@lists.squeakfoundation.org</a>> im Auftrag von Chris Muller <<a href="mailto:asqueaker@gmail.com" target="_blank">asqueaker@gmail.com</a>><br>
<b>Gesendet:</b> Mittwoch, 6. November 2019 00:27:27<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] CommandLineUIManager</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Hi Christoph,</div>
<div><br>
</div>
<div>I don't know if you're actually looking for an interactive REPL, but if all you need is to run a script...</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div dir="ltr">
<div id="m_-41324370072627956gmail-m_1502669873579509278m_5883749803210323684m_-9216229290145765267m_-8264277002231197698m_6746035779098277513gmail-m_-1046624259523574497x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif">
<p>Exactly. If you run a simple script such as [<span>HelpIcons squeakIcon writeOnFileNamed: 'testicon.png'] in headless mode and testicon.png already exists, the execution will be halted and the VM is waiting for a user interaction that will never happen.
 It would be much nicer to get a prompt via stdout + stdin to answer.</span></p>
</div>
</div>
</div>
</blockquote>
<div>... then you only need to wrap your expression in a Smalltalk run: [ ... ] block.  For example, if you wrap your expression and put it into some file, say, "<a href="http://script.st" target="_blank">script.st</a>", <br>
</div>
<div><br>
</div>
<div>              "contents of <a href="http://script.st" target="_blank">script.st</a>"</div>
<div>              Smalltalk run: [HelpIcons squeakIcon writeOnFileNamed: 'testicon.png']<br>
</div>
<div><br>
</div>
<div>then, it'll be ready for headless, you can:</div>
<div><br>
</div>
<div>          squeak -vm display=none my.image <a href="http://script.st" target="_blank">
script.st</a> > my.out 2>&1</div>
<div><br>
</div>
<div>and it'll redirect all stdout and stderr to file "my.out".  All uncaught exceptions (except Halt, I think) are handled and printed.</div>
<div><br>
</div>
<div>For servers, one thing I also put at the beginning my run block is:</div>
<div><br>
</div>
<div>       Smalltalk mitigateIfHeadless</div>
<div><br>
</div>
<div>which starts the RFB server, only if it's in headless mode, so I can get in there if I need to.</div>
<div><br>
</div>
<div>HTH,</div>
<div>  Chris</div>
<div><br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div dir="ltr">
<div id="m_-41324370072627956gmail-m_1502669873579509278m_5883749803210323684m_-9216229290145765267m_-8264277002231197698m_6746035779098277513gmail-m_-1046624259523574497x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif">
<p><span><br>
</span></p>
<p>And even if the VM is run in a read-only shell, you would at least know <i>why</i> it does not continue to execute. For example, this would be helpful on smalltalkCI - if you had not caught all ProvideAnswerNotifications in your tests, you would basically
 have no hint why you get a timeout.</p>
<p><br>
</p>
<p>I know Squeak is primarily made for use in a VM window, but nonetheless, I would love to have an implementation similar to
<a href="https://github.com/StephanEggermont/pharo/blob/development/src/UIManager/CommandLineUIManager.class.st#L104" target="_blank">
this one for Pharo</a> in Squeak.</p>
<p><br>
</p>
<p>Best,</p>
<p>Christoph</p>
<div id="m_-41324370072627956gmail-m_1502669873579509278m_5883749803210323684m_-9216229290145765267m_-8264277002231197698m_6746035779098277513gmail-m_-1046624259523574497x_Signature">
<div name="x_divtagdefaultwrapper">
<div><font color="#808080" size="2"></font></div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="m_-41324370072627956gmail-m_1502669873579509278m_5883749803210323684m_-9216229290145765267m_-8264277002231197698m_6746035779098277513gmail-m_-1046624259523574497x_divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org" target="_blank">squeak-dev-bounces@lists.squeakfoundation.org</a>> im Auftrag von tim Rowledge <<a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>><br>
<b>Gesendet:</b> Freitag, 1. November 2019 20:01:50<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] CommandLineUIManager</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt">
<div><br>
<br>
> On 2019-11-01, at 11:29 AM, Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de" target="_blank">Christoph.Thiede@student.hpi.uni-potsdam.de</a>> wrote:<br>
> <br>
> Hi all,<br>
> <br>
> does Squeak already support something like a CommandLineUIManager?<br>
<br>
We discussed some stuff around this topic back in May '19 relating to "Running Squeak fro ma unix shell script file with #! squeak..." (including the spilling mistook).<br>
<br>
And don't forget CommandShell (<a href="http://map.squeak.org/package/2c3b916b-75e2-455b-b25d-eba1bbc94b84" target="_blank">http://map.squeak.org/package/2c3b916b-75e2-455b-b25d-eba1bbc94b84</a>), OSProcess (<a href="http://map.squeak.org/package/812c9d14-5236-4cad-82ea-cc3e3837e30d" target="_blank">http://map.squeak.org/package/812c9d14-5236-4cad-82ea-cc3e3837e30d</a>),
 and Eliot's simple exemplar REPL thing (<a></a><a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/image/LoadReader.st" target="_blank">https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/image/LoadReader.st</a> &
<a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/image/StartReader.st" target="_blank">
https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/image/StartReader.st</a>)<br>
<br>
I also see that <a href="http://www.squeaksource.com/@azqxWT7-o5bjyYS2/vd0deS9q" target="_blank">
http://www.squeaksource.com/@azqxWT7-o5bjyYS2/vd0deS9q</a> claims to include a REPL package (never tried it, see also
<a href="http://gulik.pbworks.com/w/page/7760030/REPLServer" target="_blank">http://gulik.pbworks.com/w/page/7760030/REPLServer</a>)<br>
<br>
And I'm sure Craig has done something related but I simply cannot get google to find it right now<br>
<br>
tim<br>
--<br>
tim Rowledge; <a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>;
<a href="http://www.rowledge.org/tim" target="_blank">http://www.rowledge.org/tim</a><br>
 Negligent (adj.), describes a condition in which you absentmindedly answer the door in your nightgown.<br>
<br>
<br>
<br>
</div>
</span></font></div>
<br>
</blockquote>
</div>
</div>
</div>
</div>

<br>
</blockquote></div></div>