Hi,
STCommandLineHandler>>#end is defined as: --- | quit | quit := self commandLine hasOption: 'quit'. (self commandLine hasOption: 'save') ifTrue: [ Smalltalk snapshot: true andQuit: quit ]. quit ifTrue: [ self exitSuccess ]. --- Can this be simplified to: ^Smalltalk snapshot: (self hasOption: 'save') andQuit: (self hasOption: 'quit') Is it necessary to call exitSuccess when only '--quit' is given? Regards .. Subbu |
> On 17 May 2017, at 13:29, K K Subbu <[hidden email]> wrote: > > Hi, > > STCommandLineHandler>>#end is defined as: > --- > | quit | > quit := self commandLine hasOption: 'quit'. > (self commandLine hasOption: 'save') > ifTrue: [ Smalltalk snapshot: true andQuit: quit ]. > quit > ifTrue: [ self exitSuccess ]. > --- > Can this be simplified to: > > ^Smalltalk snapshot: (self hasOption: 'save') > andQuit: (self hasOption: 'quit') > > Is it necessary to call exitSuccess when only '--quit' is given? Yes. #exitSuccess does a bit more: 1. return an exit code to the command line 2. print a message 3. check if the session has changed 4. allows for overriding and special handling of the Exit exception. You should not assume that nobody needs that :) Cheers, Max > > Regards .. Subbu > |
On Wednesday 17 May 2017 05:12 PM, Max Leske wrote:
> Yes. #exitSuccess does a bit more: > 1. return an exit code to the command line > 2. print a message > 3. check if the session has changed > 4. allows for overriding and special handling of the Exit exception. > > You should not assume that nobody needs that :) Thanks for the quick clarification. I am trying to understand the difference between using quit and save/quit. exitSuccess never gets called when both options "--save --quit" are given. Shouldn't the code handle this case as well: (self hasOption: 'save') ifTrue: [ Smalltalk snapshot: true andQuit: false ]. (self hasOption: 'quit') ifTrue: [ self exitSuccess ]. Regards .. Subbu |
> On 17 May 2017, at 14:24, K K Subbu <[hidden email]> wrote: > > On Wednesday 17 May 2017 05:12 PM, Max Leske wrote: >> Yes. #exitSuccess does a bit more: >> 1. return an exit code to the command line >> 2. print a message >> 3. check if the session has changed >> 4. allows for overriding and special handling of the Exit exception. >> >> You should not assume that nobody needs that :) > > Thanks for the quick clarification. I am trying to understand the difference between using quit and save/quit. exitSuccess never gets called when both options "--save --quit" are given. Shouldn't the code handle this case as well: > > (self hasOption: 'save') > ifTrue: [ Smalltalk snapshot: true andQuit: false ]. > (self hasOption: 'quit') > ifTrue: [ self exitSuccess ]. Yes, I think so. But you have to be careful there. Imagine that you first save with "Smalltalk snapshot: true andQuit: false" and then you check for 'quit' and send #exitSuccess. What will happen after the next startup is that the execution will arrive at the *same point*. It will check 'quit' and exit as before, you will not be able to get back in to the image. You should definitely try playing around with that, just be sure to make a copy of your image first :) Cheers, Max > > Regards .. Subbu > |
On 17 May 2017 at 14:34, Max Leske <[hidden email]> wrote: > (self hasOption: 'save') | quit | quit := self commandLine hasOption: 'quit'. (self commandLine hasOption: 'save') ifTrue: [ Smalltalk snapshot: true andQuit: quit ]. quit ifTrue: [ self exitSuccess ]. Here I'm guessing if you --save --quit then the image will get saved, and next time it wakes up, enters the second conditional and #exitSuccess… confusing :/ -- |
Very. When I look at this code, without going into the image and look, I would say that it will lead to exactly what I described: the image will start and exit again immediately. |
In reply to this post by Damien Pollet
On Wednesday 17 May 2017 06:53 PM, Damien Pollet wrote:
> > | quit | > quit := self commandLine hasOption: 'quit'. > (self commandLine hasOption: 'save') > ifTrue: [ Smalltalk snapshot: true andQuit: quit ]. > quit > ifTrue: [ self exitSuccess ]. > > Here I'm guessing if you --save --quit then the image will get saved, > and next time it wakes up, enters the second conditional and > #exitSuccess… confusing :/ Thank you for making it clear. This is what intrigued me. I see many instances in pharo-project/pharo git where "--save --quit" is used. e.g. scripts/export.sh:./pharo Pharo.image --save --quit ${PWD}/export.st Regards .. Subbu |
Free forum by Nabble | Edit this page |