The Trunk: System-dtl.1062.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-dtl.1062.mcz

commits-2
David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.1062.mcz

==================== Summary ====================

Name: System-dtl.1062
Author: dtl
Time: 5 May 2019, 10:54:56.642077 pm
UUID: c527ef41-51fb-4e49-b00a-90a9a09a935d
Ancestors: System-cmm.1061

If CodeLoader is loading a script that begins with a Unix shebang line, then skip over line one of the script. This accomodates the case of an executable Unix shell script that starts a Squeak image, then feeds itself to Squeak as a start script. For example, an executable script file might contain this:

#!/usr/local/bin/squeak --
Transcript show: 'Hello, world'; cr.

=============== Diff against System-cmm.1061 ===============

Item was added:
+ ----- Method: CodeLoader>>allButShebangLine: (in category 'private') -----
+ allButShebangLine: contentsString
+ "If tontentsString begins with '#!!' then assume that it contains a Unix
+ shebang line should be skipped prior to evaluating the contents."
+
+ (contentsString beginsWith: '#!!')
+ ifTrue: [contentsString lineIndicesDo: [:line :end :endOfLine |
+ ^ contentsString allButFirst: endOfLine ]]
+ ifFalse: [^ contentsString]
+
+ " CodeLoader new allButShebangLine:
+ '#!!/usr/llocal/bin/squeak --
+ Transcript cr; show: ''Hello world!!''
+ ' "!

Item was changed:
  ----- Method: CodeLoader>>installSourceFile: (in category 'installing') -----
  installSourceFile: aStream
  "Install the previously loaded source file"
  | contents trusted |
  aStream ifNil:[^self error:'No content to install'].
  trusted := SecurityManager default positionToSecureContentsOf: aStream.
  trusted ifFalse:[(SecurityManager default enterRestrictedMode)
  ifFalse:[ aStream close.
  ^ self error:'Insecure content encountered']].
+ contents := self allButShebangLine: aStream upToEnd unzipped asString.
- contents := aStream upToEnd unzipped asString.
  (aStream respondsTo: #close) ifTrue:[aStream close].
  ^contents readStream fileIn!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-dtl.1062.mcz

Squeak - Dev mailing list
Is that #! or #!!

/————————————————————/
For encrypted mail use [hidden email]
Get a free account at ProtonMail.com

On May 5, 2019, at 19:55, [hidden email] wrote:

David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.1062.mcz

==================== Summary ====================

Name: System-dtl.1062
Author: dtl
Time: 5 May 2019, 10:54:56.642077 pm
UUID: c527ef41-51fb-4e49-b00a-90a9a09a935d
Ancestors: System-cmm.1061

If CodeLoader is loading a script that begins with a Unix shebang line, then skip over line one of the script. This accomodates the case of an executable Unix shell script that starts a Squeak image, then feeds itself to Squeak as a start script. For example, an executable script file might contain this:

#!/usr/local/bin/squeak --
Transcript show: 'Hello, world'; cr.

=============== Diff against System-cmm.1061 ===============

Item was added:
+ ----- Method: CodeLoader>>allButShebangLine: (in category 'private') -----
+ allButShebangLine: contentsString
+    "If tontentsString begins with '#!!' then assume that it contains a Unix
+    shebang line should be skipped prior to evaluating the contents."
+    
+    (contentsString beginsWith: '#!!')
+        ifTrue: [contentsString lineIndicesDo: [:line :end :endOfLine |
+            ^ contentsString allButFirst: endOfLine ]]
+        ifFalse: [^ contentsString]
+
+    " CodeLoader new allButShebangLine:
+ '#!!/usr/llocal/bin/squeak --
+ Transcript cr; show: ''Hello world!!''
+ ' "!

Item was changed:
 ----- Method: CodeLoader>>installSourceFile: (in category 'installing') -----
 installSourceFile: aStream
     "Install the previously loaded source file"
     | contents trusted |
     aStream ifNil:[^self error:'No content to install'].
     trusted := SecurityManager default positionToSecureContentsOf: aStream.
     trusted ifFalse:[(SecurityManager default enterRestrictedMode)
                     ifFalse:[ aStream close.
                             ^ self error:'Insecure content encountered']].
+    contents := self allButShebangLine: aStream upToEnd unzipped asString.
-    contents := aStream upToEnd unzipped asString.
     (aStream respondsTo: #close) ifTrue:[aStream close].
     ^contents readStream fileIn!




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-dtl.1062.mcz

David T. Lewis
On Sun, May 05, 2019 at 08:01:08PM -0700, John Pfersich via Squeak-dev wrote:
> Is that #! or #!!

It is #! in the code. I think the diffs to the mailing list are probably
made with Smalltalk fileOut chunk format, in which ! is a special character
that needs to be escaped as !!.

Dave


>
> /????????????????????????????????????????????????????????????/
> For encrypted mail use [hidden email]
> Get a free account at ProtonMail.com
> Web: www.objectnets.net and www.objectnets.org
>
> > On May 5, 2019, at 19:55, [hidden email] wrote:
> >
> > David T. Lewis uploaded a new version of System to project The Trunk:
> > http://source.squeak.org/trunk/System-dtl.1062.mcz
> >
> > ==================== Summary ====================
> >
> > Name: System-dtl.1062
> > Author: dtl
> > Time: 5 May 2019, 10:54:56.642077 pm
> > UUID: c527ef41-51fb-4e49-b00a-90a9a09a935d
> > Ancestors: System-cmm.1061
> >
> > If CodeLoader is loading a script that begins with a Unix shebang line, then skip over line one of the script. This accomodates the case of an executable Unix shell script that starts a Squeak image, then feeds itself to Squeak as a start script. For example, an executable script file might contain this:
> >
> > #!/usr/local/bin/squeak --
> > Transcript show: 'Hello, world'; cr.
> >
> > =============== Diff against System-cmm.1061 ===============
> >
> > Item was added:
> > + ----- Method: CodeLoader>>allButShebangLine: (in category 'private') -----
> > + allButShebangLine: contentsString
> > +    "If tontentsString begins with '#!!' then assume that it contains a Unix
> > +    shebang line should be skipped prior to evaluating the contents."
> > +    
> > +    (contentsString beginsWith: '#!!')
> > +        ifTrue: [contentsString lineIndicesDo: [:line :end :endOfLine |
> > +            ^ contentsString allButFirst: endOfLine ]]
> > +        ifFalse: [^ contentsString]
> > +
> > +    " CodeLoader new allButShebangLine:
> > + '#!!/usr/llocal/bin/squeak --
> > + Transcript cr; show: ''Hello world!!''
> > + ' "!
> >
> > Item was changed:
> >  ----- Method: CodeLoader>>installSourceFile: (in category 'installing') -----
> >  installSourceFile: aStream
> >      "Install the previously loaded source file"
> >      | contents trusted |
> >      aStream ifNil:[^self error:'No content to install'].
> >      trusted := SecurityManager default positionToSecureContentsOf: aStream.
> >      trusted ifFalse:[(SecurityManager default enterRestrictedMode)
> >                      ifFalse:[ aStream close.
> >                              ^ self error:'Insecure content encountered']].
> > +    contents := self allButShebangLine: aStream upToEnd unzipped asString.
> > -    contents := aStream upToEnd unzipped asString.
> >      (aStream respondsTo: #close) ifTrue:[aStream close].
> >      ^contents readStream fileIn!
> >
> >

>


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-dtl.1062.mcz

Tobias Pape

> On 07.05.2019, at 00:44, David T. Lewis <[hidden email]> wrote:
>
> On Sun, May 05, 2019 at 08:01:08PM -0700, John Pfersich via Squeak-dev wrote:
>> Is that #! or #!!
>
> It is #! in the code. I think the diffs to the mailing list are probably
> made with Smalltalk fileOut chunk format, in which ! is a special character
> that needs to be escaped as !!.
>
It is.
        -t

> Dave
>
>
>>
>> /????????????????????????????????????????????????????????????/
>> For encrypted mail use [hidden email]
>> Get a free account at ProtonMail.com
>> Web: www.objectnets.net and www.objectnets.org
>>
>>> On May 5, 2019, at 19:55, [hidden email] wrote:
>>>
>>> David T. Lewis uploaded a new version of System to project The Trunk:
>>> http://source.squeak.org/trunk/System-dtl.1062.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: System-dtl.1062
>>> Author: dtl
>>> Time: 5 May 2019, 10:54:56.642077 pm
>>> UUID: c527ef41-51fb-4e49-b00a-90a9a09a935d
>>> Ancestors: System-cmm.1061
>>>
>>> If CodeLoader is loading a script that begins with a Unix shebang line, then skip over line one of the script. This accomodates the case of an executable Unix shell script that starts a Squeak image, then feeds itself to Squeak as a start script. For example, an executable script file might contain this:
>>>
>>> #!/usr/local/bin/squeak --
>>> Transcript show: 'Hello, world'; cr.
>>>
>>> =============== Diff against System-cmm.1061 ===============
>>>
>>> Item was added:
>>> + ----- Method: CodeLoader>>allButShebangLine: (in category 'private') -----
>>> + allButShebangLine: contentsString
>>> +    "If tontentsString begins with '#!!' then assume that it contains a Unix
>>> +    shebang line should be skipped prior to evaluating the contents."
>>> +    
>>> +    (contentsString beginsWith: '#!!')
>>> +        ifTrue: [contentsString lineIndicesDo: [:line :end :endOfLine |
>>> +            ^ contentsString allButFirst: endOfLine ]]
>>> +        ifFalse: [^ contentsString]
>>> +
>>> +    " CodeLoader new allButShebangLine:
>>> + '#!!/usr/llocal/bin/squeak --
>>> + Transcript cr; show: ''Hello world!!''
>>> + ' "!
>>>
>>> Item was changed:
>>> ----- Method: CodeLoader>>installSourceFile: (in category 'installing') -----
>>> installSourceFile: aStream
>>>     "Install the previously loaded source file"
>>>     | contents trusted |
>>>     aStream ifNil:[^self error:'No content to install'].
>>>     trusted := SecurityManager default positionToSecureContentsOf: aStream.
>>>     trusted ifFalse:[(SecurityManager default enterRestrictedMode)
>>>                     ifFalse:[ aStream close.
>>>                             ^ self error:'Insecure content encountered']].
>>> +    contents := self allButShebangLine: aStream upToEnd unzipped asString.
>>> -    contents := aStream upToEnd unzipped asString.
>>>     (aStream respondsTo: #close) ifTrue:[aStream close].
>>>     ^contents readStream fileIn!
>>>
>>>
>
>>
>
>