This file is indexed.

/usr/share/gnu-smalltalk/scripts/Load.st is in gnu-smalltalk-common 3.2.4-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
"======================================================================
|
|   Smalltalk package loader (utility script)
|
|
 ======================================================================"


"======================================================================
|
| Copyright 1999, 2000, 2002, 2004, 2008, 2009 Free Software Foundation, Inc.
| Written by Paolo Bonzini.
|
| This file is part of GNU Smalltalk.
|
| GNU Smalltalk is free software; you can redistribute it and/or modify it
| under the terms of the GNU General Public License as published by the Free
| Software Foundation; either version 2, or (at your option) any later version.
| 
| GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
| FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
| details.
| 
| You should have received a copy of the GNU General Public License along with
| GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
| Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  
|
 ======================================================================"

Smalltalk arguments isEmpty ifTrue: [ ObjectMemory quit ]!

| helpString quiet verbose wasVerbose snapshot force test sunit packages
  startMessage |
snapshot := true.
quiet := false.
verbose := false.
force := false.
test := false.
startMessage := nil.
wasVerbose := FileStream verbose: false.
packages := OrderedCollection new.
sunit := ''.

helpString :=
'Usage:
    gst-load [ flag ... ] package ...

Options:
    -q --quiet            hide the output
    -v --verbose          show loaded files
    -f --force            reload package if already loaded
    -n --dry-run          don''t save the image after loading
    -t --test             run SUnit tests if available
       --start[=ARG]      start the package and keep running the image
    -i --rebuild-image    load into a newly-created image
    -I --image-file=FILE  load into the specified image
       --kernel-dir=PATH  use the specified kernel directory
    -h --help             show this message
       --version          print version information and exit

'.

"Parse the command-line arguments."
Smalltalk
    arguments: '-h|--help --version -q|--quiet -v|-V|--verbose -n|--dry-run
		-f|--force -t|--test -I|--image-file: --kernel-directory:
		--start:: -i|--rebuild-image'
    do: [ :opt :arg |

    opt = 'help' ifTrue: [
	helpString displayOn: stdout.
	ObjectMemory quit: 0 ].

    opt = 'version' ifTrue: [
	('gst-load - %1' % {Smalltalk version}) displayNl.
	ObjectMemory quit: 0 ].

    opt = 'quiet' ifTrue: [
	OutputVerbosity := 0.
	quiet := true.
	verbose := false.
	wasVerbose := FileStream verbose: false ].

    opt = 'verbose' ifTrue: [
	OutputVerbosity := 1.
	quiet := false.
	verbose := true.
	wasVerbose := FileStream verbose: true ].

    opt = 'force' ifTrue: [
	force := true ].

    opt = 'test' ifTrue: [
	test := true ].

    opt = 'start' ifTrue: [
	startMessage := Message
	    selector: (arg isNil ifTrue: [ #start ] ifFalse: [ #start: ])
	    arguments: (arg isNil ifTrue: [ #() ] ifFalse: [ { arg } ]) ].

    opt = 'dry-run' ifTrue: [
	snapshot := false ].

    opt isNil ifTrue: [ packages add: arg ] ]

    ifError: [
	helpString displayOn: stderr.
	ObjectMemory quit: 1 ].

force ifTrue: [
    packages do: [ :each | Smalltalk removeFeature: each asSymbol ] ].

[
    packages := packages collect: [ :each | PackageLoader packageAt: each ].

    (startMessage notNil and: [
	startMessage selector == #start: and: [
	(packages count: [ :each | each startScript notNil ]) > 1]]) ifTrue: [
	    stderr nextPutAll: 'gst-load: Cannot pass start argument to multiple packages
'.
	    ^self ].

    packages do: [ :each |
	each fileIn.
        sunit := sunit, ' ', each sunitScript ] ]
    ifCurtailed: [ ObjectMemory quit: 1 ].

wasVerbose := FileStream verbose: wasVerbose.

test
    ifTrue: [
	| tmpFile tmpFileName result |
	snapshot ifTrue: [
	    tmpFile := FileDescriptor openTemporaryFile: Directory temporary / 'im-'.
	    tmpFileName := tmpFile name.
	    ObjectMemory snapshot: tmpFileName.
	    wasVerbose := FileStream verbose: wasVerbose ].

	packages do: [ :each |
	    each test isNil ifFalse: [
		each test fileIn.
		sunit := sunit, ' ', each test sunitScript ] ].

	result := (Smalltalk at: #TestSuitesScripter)
	    run: sunit quiet: quiet verbose: verbose.
	result runCount = result passedCount ifFalse: [ ObjectMemory quit: 1 ].

	snapshot ifTrue: [
	    (FileDescriptor open: File image mode: FileStream write)
		nextPutAll: tmpFile.
	    tmpFile close.
	    (File name: tmpFileName) remove ] ]

    ifFalse: [
	snapshot ifTrue: [ ObjectMemory snapshot ] ].

(startMessage notNil and: [ 
    packages anySatisfy: [ :pkg | pkg startScript notNil ]])
	ifFalse: [ ObjectMemory quit ].

packages do: [ :each | each perform: startMessage ].
Processor activeProcess suspend!