| | | |
Offset 1, 666 lines modified | Offset 1, 760 lines modified |
1 | .\"Ruby·is·copyrighted·by·Yukihiro·Matsumoto·<matz@netlab.jp>. | |
2 | .Dd·April·14,·2018 | |
3 | .Dt·RUBY·\&1·"Ruby·Programmer's·Reference·Guide" | 1 | .TH·RUBY·\&1·"Ruby·Programmer's·Reference·Guide"·"April·14,·2018"·"UNIX" |
4 | .Os·UNIX | |
5 | .Sh·NAME | 2 | .SH·NAME |
6 | .Nm·ruby | 3 | \fBruby\fP |
7 | .Nd·Interpreted·object-oriented·scripting·language | 4 | \-·Interpreted·object-oriented·scripting·language |
8 | .Sh·SYNOPSIS | 5 | .SH·SYNOPSIS |
9 | .Nm | |
10 | .Op·Fl·-copyright | |
11 | .Op·Fl·-version | |
12 | .Op·Fl·SUacdlnpswvy | |
13 | .Op·Fl·0·Ns·Op·Ar·octal | |
14 | .Op·Fl·C·Ar·directory | |
15 | .Op·Fl·E·Ar·external·Ns·Op·:·Ns·Ar·internal | |
16 | .Op·Fl·F·Ns·Op·Ar·pattern | |
17 | .Op·Fl·I·Ar·directory | |
18 | .Op·Fl·K·Ns·Op·Ar·c | |
19 | .Op·Fl·T·Ns·Op·Ar·level | |
20 | .Op·Fl·W·Ns·Op·Ar·level | |
21 | .Op·Fl·e·Ar·command | |
22 | .Op·Fl·i·Ns·Op·Ar·extension | |
23 | .Op·Fl·r·Ar·library | |
24 | .Op·Fl·x·Ns·Op·Ar·directory | |
25 | .Op·Fl·-·Ns·Bro·Cm·enable·Ns·|·Ns·Cm·disable·Brc·Ns·-·Ns·Ar·FEATURE | |
26 | .Op·Fl·-dump·Ns·=·Ns·Ar·target | |
27 | .Op·Fl·-verbose | |
28 | .Op·Fl·- | |
29 | .Op·Ar·program_file | |
30 | .Op·Ar·argument·... | 6 | .br |
| 7 | \fBruby\fP |
| 8 | [\fB\--copyright\fP] |
| 9 | [\fB\--version\fP] |
| 10 | [\fB\-SUacdlnpswvy\fP] |
| 11 | [\fB\-0\fP[\fIoctal\fP]] |
| 12 | [\fB\-C\fP·\fIdirectory\fP] |
| 13 | [\fB\-E\fP·\fIexternal\fP[:\fIinternal\fP]] |
| 14 | [\fB\-F\fP[\fIpattern\fP]] |
| 15 | [\fB\-I\fP·\fIdirectory\fP] |
| 16 | [\fB\-K\fP[\fIc\fP]] |
| 17 | [\fB\-T\fP[\fIlevel\fP]] |
| 18 | [\fB\-W\fP[\fIlevel\fP]] |
| 19 | [\fB\-e\fP·\fIcommand\fP] |
| 20 | [\fB\-i\fP[\fIextension\fP]] |
| 21 | [\fB\-r\fP·\fIlibrary\fP] |
| 22 | [\fB\-x\fP[\fIdirectory\fP]] |
| 23 | [\fB\--\fP{\fBenable\fP|\fBdisable\fP}-\fIFEATURE\fP] |
| 24 | [\fB\--dump\fP=\fItarget\fP] |
| 25 | [\fB\--verbose\fP] |
| 26 | [\fB\--\fP] |
| 27 | [\fIprogram_file\fP] |
| 28 | [\fIargument\fP·...] |
31 | .Sh·DESCRIPTION | 29 | .SH·DESCRIPTION |
32 | Ruby·is·an·interpreted·scripting·language·for·quick·and·easy | 30 | Ruby·is·an·interpreted·scripting·language·for·quick·and·easy |
33 | object-oriented·programming.··It·has·many·features·to·process·text | 31 | object-oriented·programming.··It·has·many·features·to·process·text |
34 | files·and·to·do·system·management·tasks·(like·in·Perl).··It·is·simple, | 32 | files·and·to·do·system·management·tasks·(like·in·Perl).··It·is·simple, |
35 | straight-forward,·and·extensible. | 33 | straight-forward,·and·extensible. |
36 | .Pp | |
37 | If·you·want·a·language·for·easy·object-oriented·programming,·or·you | 34 | If·you·want·a·language·for·easy·object-oriented·programming,·or·you |
38 | don't·like·the·Perl·ugliness,·or·you·do·like·the·concept·of·LISP,·but | 35 | don't·like·the·Perl·ugliness,·or·you·do·like·the·concept·of·LISP,·but |
39 | don't·like·too·many·parentheses,·Ruby·might·be·your·language·of | 36 | don't·like·too·many·parentheses,·Ruby·might·be·your·language·of |
40 | choice. | 37 | choice. |
41 | .Sh·FEATURES | 38 | .SH·FEATURES |
42 | Ruby's·features·are·as·follows: | 39 | Ruby's·features·are·as·follows: |
43 | .Bl·-tag·-width·6n | 40 | .TP |
44 | .It·Sy·"Interpretive" | 41 | .B·"Interpretive" |
45 | Ruby·is·an·interpreted·language,·so·you·don't·have·to·recompile | 42 | Ruby·is·an·interpreted·language,·so·you·don't·have·to·recompile |
46 | programs·written·in·Ruby·to·execute·them. | 43 | programs·written·in·Ruby·to·execute·them. |
47 | .Pp | |
| 44 | .TP |
48 | .It·Sy·"Variables·have·no·type·(dynamic·typing)" | 45 | .B·"Variables·have·no·type·(dynamic·typing)" |
49 | Variables·in·Ruby·can·contain·data·of·any·type.··You·don't·have·to | 46 | Variables·in·Ruby·can·contain·data·of·any·type.··You·don't·have·to |
50 | worry·about·variable·typing.··Consequently,·it·has·a·weaker·compile | 47 | worry·about·variable·typing.··Consequently,·it·has·a·weaker·compile |
51 | time·check. | 48 | time·check. |
52 | .Pp | |
| 49 | .TP |
53 | .It·Sy·"No·declaration·needed" | 50 | .B·"No·declaration·needed" |
54 | You·can·use·variables·in·your·Ruby·programs·without·any·declarations. | 51 | You·can·use·variables·in·your·Ruby·programs·without·any·declarations. |
55 | Variable·names·denote·their·scope·-·global,·class,·instance,·or·local. | 52 | Variable·names·denote·their·scope·-·global,·class,·instance,·or·local. |
56 | .Pp | |
| 53 | .TP |
57 | .It·Sy·"Simple·syntax" | 54 | .B·"Simple·syntax" |
58 | Ruby·has·a·simple·syntax·influenced·slightly·from·Eiffel. | 55 | Ruby·has·a·simple·syntax·influenced·slightly·from·Eiffel. |
59 | .Pp | |
| 56 | .TP |
60 | .It·Sy·"No·user-level·memory·management" | 57 | .B·"No·user-level·memory·management" |
61 | Ruby·has·automatic·memory·management.··Objects·no·longer·referenced | 58 | Ruby·has·automatic·memory·management.··Objects·no·longer·referenced |
62 | from·anywhere·are·automatically·collected·by·the·garbage·collector | 59 | from·anywhere·are·automatically·collected·by·the·garbage·collector |
63 | built·into·the·interpreter. | 60 | built·into·the·interpreter. |
64 | .Pp | |
| 61 | .TP |
65 | .It·Sy·"Everything·is·an·object" | 62 | .B·"Everything·is·an·object" |
66 | Ruby·is·a·purely·object-oriented·language,·and·was·so·since·its | 63 | Ruby·is·a·purely·object-oriented·language,·and·was·so·since·its |
67 | creation.··Even·such·basic·data·as·integers·are·seen·as·objects. | 64 | creation.··Even·such·basic·data·as·integers·are·seen·as·objects. |
68 | .Pp | |
| 65 | .TP |
69 | .It·Sy·"Class,·inheritance,·and·methods" | 66 | .B·"Class,·inheritance,·and·methods" |
70 | Being·an·object-oriented·language,·Ruby·naturally·has·basic | 67 | Being·an·object-oriented·language,·Ruby·naturally·has·basic |
71 | features·like·classes,·inheritance,·and·methods. | 68 | features·like·classes,·inheritance,·and·methods. |
72 | .Pp | |
| 69 | .TP |
73 | .It·Sy·"Singleton·methods" | 70 | .B·"Singleton·methods" |
74 | Ruby·has·the·ability·to·define·methods·for·certain·objects.··For | 71 | Ruby·has·the·ability·to·define·methods·for·certain·objects.··For |
75 | example,·you·can·define·a·press-button·action·for·certain·widget·by | 72 | example,·you·can·define·a·press-button·action·for·certain·widget·by |
76 | defining·a·singleton·method·for·the·button.··Or,·you·can·make·up·your | 73 | defining·a·singleton·method·for·the·button.··Or,·you·can·make·up·your |
77 | own·prototype·based·object·system·using·singleton·methods,·if·you·want | 74 | own·prototype·based·object·system·using·singleton·methods,·if·you·want |
78 | to. | 75 | to. |
79 | .Pp | |
| 76 | .TP |
80 | .It·Sy·"Mix-in·by·modules" | 77 | .B·"Mix-in·by·modules" |
81 | Ruby·intentionally·does·not·have·the·multiple·inheritance·as·it·is·a | 78 | Ruby·intentionally·does·not·have·the·multiple·inheritance·as·it·is·a |
82 | source·of·confusion.··Instead,·Ruby·has·the·ability·to·share | 79 | source·of·confusion.··Instead,·Ruby·has·the·ability·to·share |
83 | implementations·across·the·inheritance·tree.··This·is·often·called·a | 80 | implementations·across·the·inheritance·tree.··This·is·often·called·a |
84 | .Sq·Mix-in·. | |
85 | .Pp | 81 | `Mix-in'. |
| |
| 82 | .TP |
86 | .It·Sy·"Iterators" | 83 | .B·"Iterators" |
87 | Ruby·has·iterators·for·loop·abstraction. | 84 | Ruby·has·iterators·for·loop·abstraction. |
88 | .Pp | |
| 85 | .TP |
89 | .It·Sy·"Closures" | 86 | .B·"Closures" |
90 | In·Ruby,·you·can·objectify·the·procedure. | 87 | In·Ruby,·you·can·objectify·the·procedure. |
91 | .Pp | |
| 88 | .TP |
92 | .It·Sy·"Text·processing·and·regular·expressions" | 89 | .B·"Text·processing·and·regular·expressions" |
93 | Ruby·has·a·bunch·of·text·processing·features·like·in·Perl. | 90 | Ruby·has·a·bunch·of·text·processing·features·like·in·Perl. |
94 | .Pp | |
| 91 | .TP |
95 | .It·Sy·"M17N,·character·set·independent" | 92 | .B·"M17N,·character·set·independent" |
96 | Ruby·supports·multilingualized·programming.·Easy·to·process·texts | 93 | Ruby·supports·multilingualized·programming.·Easy·to·process·texts |
97 | written·in·many·different·natural·languages·and·encoded·in·many | 94 | written·in·many·different·natural·languages·and·encoded·in·many |
98 | different·character·encodings,·without·dependence·on·Unicode. | 95 | different·character·encodings,·without·dependence·on·Unicode. |
99 | .Pp | |
| 96 | .TP |
100 | .It·Sy·"Bignums" | 97 | .B·"Bignums" |
101 | With·built-in·bignums,·you·can·for·example·calculate·factorial(400). | 98 | With·built-in·bignums,·you·can·for·example·calculate·factorial(400). |
102 | .Pp | |
| 99 | .TP |
103 | .It·Sy·"Reflection·and·domain·specific·languages" | 100 | .B·"Reflection·and·domain·specific·languages" |
104 | Class·is·also·an·instance·of·the·Class·class.·Definition·of·classes·and·methods | 101 | Class·is·also·an·instance·of·the·Class·class.·Definition·of·classes·and·methods |
105 | is·an·expression·just·as·1+1·is.·So·your·programs·can·even·write·and·modify·programs. | 102 | is·an·expression·just·as·1+1·is.·So·your·programs·can·even·write·and·modify·programs. |
106 | Thus·you·can·write·your·application·in·your·own·programming·language·on·top·of·Ruby. | 103 | Thus·you·can·write·your·application·in·your·own·programming·language·on·top·of·Ruby. |
107 | .Pp | |
| 104 | .TP |
108 | .It·Sy·"Exception·handling" | 105 | .B·"Exception·handling" |
109 | As·in·Java(tm). | 106 | As·in·Java(tm). |
110 | .Pp | |
| 107 | .TP |
111 | .It·Sy·"Direct·access·to·the·OS" | 108 | .B·"Direct·access·to·the·OS" |
112 | Ruby·can·use·most | 109 | Ruby·can·use·most |
113 | .Ux | 110 | UNIX |
114 | system·calls,·often·used·in·system·programming. | 111 | system·calls,·often·used·in·system·programming. |
115 | .Pp | |
| 112 | .TP |
116 | .It·Sy·"Dynamic·loading" | 113 | .B·"Dynamic·loading" |
117 | On·most | 114 | On·most |
118 | .Ux | 115 | UNIX |
119 | systems,·you·can·load·object·files·into·the·Ruby·interpreter | 116 | systems,·you·can·load·object·files·into·the·Ruby·interpreter |
120 | on-the-fly. | 117 | on-the-fly. |
| 118 | .TP |
121 | .It·Sy·"Rich·libraries" | 119 | .B·"Rich·libraries" |
122 | In·addition·to·the | 120 | In·addition·to·the |
123 | .Dq·builtin·libraries | 121 | ``builtin·libraries'' |
124 | and | 122 | and |
125 | .Dq·standard·libraries | 123 | ``standard·libraries'' |
126 | that·are·bundled·with·Ruby,·a·vast·amount·of·third-party·libraries | 124 | that·are·bundled·with·Ruby,·a·vast·amount·of·third-party·libraries |
127 | .Pq·Dq·gems | 125 | (``gems'') |
128 | are·available·via·the·package·management·system·called | 126 | are·available·via·the·package·management·system·called |
129 | .Sq·RubyGems·, | 127 | `RubyGems', |
130 | namely·the | 128 | namely·the |
131 | .Xr·gem·1 | 129 | \fBgem\fP(1) |
132 | command.··Visit·RubyGems.org | 130 | command.··Visit·RubyGems.org |
133 | .Pq·Lk·https://rubygems.org/ | 131 | (\fBhttps://rubygems.org/\fP) |
134 | to·find·the·gems·you·need,·and·explore·GitHub | 132 | to·find·the·gems·you·need,·and·explore·GitHub |
135 | .Pq·Lk·https://github.com/ | 133 | (\fBhttps://github.com/\fP) |
136 | to·see·how·they·are·being·developed·and·used. | 134 | to·see·how·they·are·being·developed·and·used. |
| |
137 | .El | |
138 | .Pp | |
139 | .Sh·OPTIONS | 135 | .SH·OPTIONS |
140 | The·Ruby·interpreter·accepts·the·following·command-line·options·(switches). | 136 | The·Ruby·interpreter·accepts·the·following·command-line·options·(switches). |
141 | They·are·quite·similar·to·those·of | 137 | They·are·quite·similar·to·those·of |
142 | .Xr·perl·1·. | |
143 | .Bl·-tag·-width·"1234567890123"·-compact | |
144 | .Pp | |
145 | .It·Fl·-copyright | 138 | \fBperl\fP(1). |
| |
| 139 | .TP |
| 140 | \fB\--copyright\fP |
146 | Prints·the·copyright·notice,·and·quits·immediately·without·running·any | 141 | Prints·the·copyright·notice,·and·quits·immediately·without·running·any |
147 | script. | 142 | script. |
148 | .Pp | |
149 | .It·Fl·-version | |
| 143 | .TP |
| 144 | \fB\--version\fP |
150 | Prints·the·version·of·the·Ruby·interpreter,·and·quits·immediately·without | 145 | Prints·the·version·of·the·Ruby·interpreter,·and·quits·immediately·without |
151 | running·any·script. | 146 | running·any·script. |
152 | .Pp | |
153 | .It·Fl·0·Ns·Op·Ar·octal | |
| 147 | .TP |
| 148 | \fB\-0\fP[\fIoctal\fP] |
154 | (The·digit | 149 | (The·digit |
155 | .Dq·zero·.·) | 150 | ``zero''.) |
156 | Specifies·the·input·record·separator | 151 | Specifies·the·input·record·separator |
157 | .Pf·(·Li·"$/"·) | 152 | ("$/") |
158 | as·an·octal·number.·If·no·digit·is·given,·the·null·character·is·taken | 153 | as·an·octal·number.·If·no·digit·is·given,·the·null·character·is·taken |
159 | as·the·separator.··Other·switches·may·follow·the·digits. | 154 | as·the·separator.··Other·switches·may·follow·the·digits. |
160 | .Fl·00 | 155 | \fB\-00\fP |
161 | turns·Ruby·into·paragraph·mode. | 156 | turns·Ruby·into·paragraph·mode. |
162 | .Fl·0777 | 157 | \fB\-0777\fP |
163 | makes·Ruby·read·whole·file·at·once·as·a·single·string·since·there·is | 158 | makes·Ruby·read·whole·file·at·once·as·a·single·string·since·there·is |
164 | no·legal·character·with·that·value. | 159 | no·legal·character·with·that·value. |
165 | .Pp | |
166 | .It·Fl·C·Ar·directory | |
167 | .It·Fl·X·Ar·directory | |
| 160 | .TP |
| 161 | \fB\-C\fP·\fIdirectory\fP |
| 162 | .TP |
| 163 | \fB\-X\fP·\fIdirectory\fP |
168 | Causes·Ruby·to·switch·to·the·directory. | 164 | Causes·Ruby·to·switch·to·the·directory. |
169 | .Pp | |
170 | .It·Fl·E·Ar·external·Ns·Op·:·Ns·Ar·internal | |
171 | .It·Fl·-encoding·Ar·external·Ns·Op·:·Ns·Ar·internal | |
| 165 | .TP |
| 166 | \fB\-E\fP·\fIexternal\fP[:\fIinternal\fP] |
| 167 | .TP |
| 168 | \fB\--encoding\fP·\fIexternal\fP[:\fIinternal\fP] |
172 | Specifies·the·default·value(s)·for·external·encodings·and·internal·encoding.·Values·should·be·separated·with·colon·(:). | 169 | Specifies·the·default·value(s)·for·external·encodings·and·internal·encoding.·Values·should·be·separated·with·colon·(:). |
173 | .Pp | |
174 | You·can·omit·the·one·for·internal·encodings,·then·the·value | 170 | You·can·omit·the·one·for·internal·encodings,·then·the·value |
175 | .Pf·(·Li·"Encoding.default_internal"·)·will·be·nil. | 171 | ("Encoding.default_internal")·will·be·nil. |
176 | .Pp | |
177 | .It·Fl·-external-encoding·Ns·=·Ns·Ar·encoding | |
178 | .It·Fl·-internal-encoding·Ns·=·Ns·Ar·encoding | |
| 172 | .TP |
| 173 | \fB\--external-encoding\fP=\fIencoding\fP |
| 174 | .TP |
| 175 | \fB\--internal-encoding\fP=\fIencoding\fP |
179 | Specify·the·default·external·or·internal·character·encoding | 176 | Specify·the·default·external·or·internal·character·encoding |
180 | .Pp | |
181 | .It·Fl·F·Ar·pattern | |
| 177 | .TP |
| 178 | \fB\-F\fP·\fIpattern\fP |
182 | Specifies·input·field·separator | 179 | Specifies·input·field·separator |
183 | .Pf·(·Li·"$;"·)·. | |
184 | .Pp | |
185 | .It·Fl·I·Ar·directory | 180 | ("$;"). |
| |
| 181 | .TP |
| 182 | \fB\-I\fP·\fIdirectory\fP |
186 | Used·to·tell·Ruby·where·to·load·the·library·scripts.··Directory·path | 183 | Used·to·tell·Ruby·where·to·load·the·library·scripts.··Directory·path |
187 | will·be·added·to·the·load-path·variable | 184 | will·be·added·to·the·load-path·variable |
188 | .Pf·(·Li·"$:"·)·. | |
189 | .Pp | |
190 | .It·Fl·K·Ar·kcode | 185 | ("$:"). |
| |
| 186 | .TP |
| 187 | \fB\-K\fP·\fIkcode\fP |
191 | Specifies·KANJI·(Japanese)·encoding.·The·default·value·for·script·encodings | 188 | Specifies·KANJI·(Japanese)·encoding.·The·default·value·for·script·encodings |
192 | .Pf·(·Li·"__ENCODING__"·)·and·external·encodings·(·Li·"Encoding.default_external"·)·will·be·the·specified·one. | 189 | ("__ENCODING__")·and·external·encodings·("Encoding.default_external")·will·be·the·specified·one. |
193 | .Ar·kcode | 190 | \fIkcode\fP |
194 | can·be·one·of | 191 | can·be·one·of |
195 | .Bl·-hang·-offset·indent | |
196 | .It·Sy·e | 192 | .TP |
| 193 | .B·e |
197 | EUC-JP | 194 | EUC-JP |
198 | .Pp | |
199 | .It·Sy·s | |
| 195 | .TP |
| 196 | .B·s |
200 | Windows-31J·(CP932) | 197 | Windows-31J·(CP932) |
201 | .Pp | |
202 | .It·Sy·u | |
| 198 | .TP |
| 199 | .B·u |
203 | UTF-8 | 200 | UTF-8 |
204 | .Pp | |
205 | .It·Sy·n | |
| 201 | .TP |
| 202 | .B·n |
206 | ASCII-8BIT·(BINARY) | 203 | ASCII-8BIT·(BINARY) |
207 | .El | |
208 | .Pp | |
209 | .It·Fl·S | |
| 204 | .TP |
| 205 | \fB\-S\fP |
210 | Makes·Ruby·use·the | 206 | Makes·Ruby·use·the |
211 | .Ev·PATH | 207 | .IR·PATH |
212 | environment·variable·to·search·for·script,·unless·its·name·begins | 208 | environment·variable·to·search·for·script,·unless·its·name·begins |
213 | with·a·slash.··This·is·used·to·emulate | 209 | with·a·slash.··This·is·used·to·emulate |
214 | .Li·#! | 210 | #! |
215 | on·machines·that·don't·support·it,·in·the·following·manner: | 211 | on·machines·that·don't·support·it,·in·the·following·manner: |
216 | .Bd·-literal·-offset·indent | |
217 | #!·/usr/local/bin/ruby | 212 | #!·/usr/local/bin/ruby |
| 213 | .br |
218 | #·This·line·makes·the·next·one·a·comment·in·Ruby·\e | 214 | #·This·line·makes·the·next·one·a·comment·in·Ruby·\e |
| 215 | .br |
219 | ··exec·/usr/local/bin/ruby·-S·$0·$* | 216 | ··exec·/usr/local/bin/ruby·-S·$0·$* |
220 | .Ed | |
221 | .Pp | 217 | .br |
| |
222 | On·some·systems | 218 | On·some·systems |
223 | .Li·"$0" | 219 | "$0" |
224 | does·not·always·contain·the·full·pathname,·so·you·need·the | 220 | does·not·always·contain·the·full·pathname,·so·you·need·the |
225 | .Fl·S | 221 | \fB\-S\fP |
226 | switch·to·tell·Ruby·to·search·for·the·script·if·necessary·(to·handle·embedded | 222 | switch·to·tell·Ruby·to·search·for·the·script·if·necessary·(to·handle·embedded |
227 | spaces·and·such).··A·better·construct·than | 223 | spaces·and·such).··A·better·construct·than |
228 | .Li·"$*" | 224 | "$*" |
229 | would·be | 225 | would·be |
230 | .Li·${1+"$@"}·, | 226 | ${1+"$@"}, |
231 | but·it·does·not·work·if·the·script·is·being·interpreted·by | 227 | but·it·does·not·work·if·the·script·is·being·interpreted·by |
232 | .Xr·csh·1·. | |
233 | .Pp | |
234 | .It·Fl·T·Ns·Op·Ar·level=1 | 228 | \fBcsh\fP(1). |
| |
| 229 | .TP |
| 230 | \fB\-T\fP[\fIlevel=1\fP] |
235 | Turns·on·taint·checks·at·the·specified·level·(default·1). | 231 | Turns·on·taint·checks·at·the·specified·level·(default·1). |
236 | .Pp | |
237 | .It·Fl·U | |
| 232 | .TP |
| 233 | \fB\-U\fP |
238 | Sets·the·default·value·for·internal·encodings | 234 | Sets·the·default·value·for·internal·encodings |
239 | .Pf·(·Li·"Encoding.default_internal"·)·to·UTF-8. | 235 | ("Encoding.default_internal")·to·UTF-8. |
240 | .Pp | |
241 | .It·Fl·W·Ns·Op·Ar·level=2 | |
| 236 | .TP |
| 237 | \fB\-W\fP[\fIlevel=2\fP] |
242 | Turns·on·verbose·mode·at·the·specified·level·without·printing·the·version | 238 | Turns·on·verbose·mode·at·the·specified·level·without·printing·the·version |
243 | message·at·the·beginning.·The·level·can·be; | 239 | message·at·the·beginning.·The·level·can·be; |
244 | .Bl·-hang·-offset·indent | |
245 | .It·Sy·0 | 240 | .TP |
| 241 | .B·0 |
246 | Verbose·mode·is·"silence".·It·sets·the | 242 | Verbose·mode·is·"silence".·It·sets·the |
247 | .Li·"$VERBOSE" | 243 | "$VERBOSE" |
248 | to·nil. | 244 | to·nil. |
249 | .Pp | |
250 | .It·Sy·1 | |
| 245 | .TP |
| 246 | .B·1 |
251 | Verbose·mode·is·"medium".·It·sets·the | 247 | Verbose·mode·is·"medium".·It·sets·the |
252 | .Li·"$VERBOSE" | 248 | "$VERBOSE" |
253 | to·false. | 249 | to·false. |
254 | .Pp | |
| 250 | .TP |
255 | .It·Sy·2·(default) | 251 | .B·2·(default) |
256 | Verbose·mode·is·"verbose".·It·sets·the | 252 | Verbose·mode·is·"verbose".·It·sets·the |
257 | .Li·"$VERBOSE" | 253 | "$VERBOSE" |
258 | to·true. | 254 | to·true. |
259 | .Fl·W·Ns | 255 | \fB\-W\fP |
260 | 2·is·the·same·as | 256 | 2·is·the·same·as |
| 257 | \fB\-w\fP |
| |
| 258 | .TP |
| 259 | \fB\-a\fP |
261 | .Fl·w | |
262 | . | |
263 | .El | |
264 | .Pp | |
265 | .It·Fl·a | |
266 | Turns·on·auto-split·mode·when·used·with | 260 | Turns·on·auto-split·mode·when·used·with |
267 | .Fl·n | 261 | \fB\-n\fP |
268 | or | 262 | or |
269 | .Fl·p·. | 263 | \fB\-p\fP. |
270 | In·auto-split·mode,·Ruby·executes | 264 | In·auto-split·mode,·Ruby·executes |
| 265 | .nf |
271 | .Dl·$F·=·$_.split | 266 | \&··$F·=·$_.split |
| 267 | .fi |
272 | at·beginning·of·each·loop. | 268 | at·beginning·of·each·loop. |
273 | .Pp | |
274 | .It·Fl·c | |
| 269 | .TP |
| 270 | \fB\-c\fP |
275 | Causes·Ruby·to·check·the·syntax·of·the·script·and·exit·without | 271 | Causes·Ruby·to·check·the·syntax·of·the·script·and·exit·without |
276 | executing.·If·there·are·no·syntax·errors,·Ruby·will·print | 272 | executing.·If·there·are·no·syntax·errors,·Ruby·will·print |
277 | .Dq·Syntax·OK | 273 | ``Syntax·OK'' |
278 | to·the·standard·output. | 274 | to·the·standard·output. |
279 | .Pp | |
280 | .It·Fl·d | |
281 | .It·Fl·-debug | |
| 275 | .TP |
| 276 | \fB\-d\fP |
| 277 | .TP |
| 278 | \fB\--debug\fP |
282 | Turns·on·debug·mode. | 279 | Turns·on·debug·mode. |
283 | .Li·"$DEBUG" | 280 | "$DEBUG" |
284 | will·be·set·to·true. | 281 | will·be·set·to·true. |
285 | .Pp | |
286 | .It·Fl·e·Ar·command | |
| 282 | .TP |
| 283 | \fB\-e\fP·\fIcommand\fP |
287 | Specifies·script·from·command-line·while·telling·Ruby·not·to·search | 284 | Specifies·script·from·command-line·while·telling·Ruby·not·to·search |
288 | the·rest·of·the·arguments·for·a·script·file·name. | 285 | the·rest·of·the·arguments·for·a·script·file·name. |
289 | .Pp | |
290 | .It·Fl·h | |
291 | .It·Fl·-help | |
| 286 | .TP |
| 287 | \fB\-h\fP |
| 288 | .TP |
| 289 | \fB\--help\fP |
292 | Prints·a·summary·of·the·options. | 290 | Prints·a·summary·of·the·options. |
293 | .Pp | |
294 | .It·Fl·i·Ar·extension | |
| 291 | .TP |
| 292 | \fB\-i\fP·\fIextension\fP |
295 | Specifies·in-place-edit·mode.··The·extension,·if·specified,·is·added | 293 | Specifies·in-place-edit·mode.··The·extension,·if·specified,·is·added |
296 | to·old·file·name·to·make·a·backup·copy.··For·example: | 294 | to·old·file·name·to·make·a·backup·copy.··For·example: |
297 | .Bd·-literal·-offset·indent | |
298 | %·echo·matz·>·/tmp/junk | 295 | %·echo·matz·>·/tmp/junk |
| 296 | .br |
299 | %·cat·/tmp/junk | 297 | %·cat·/tmp/junk |
| 298 | .br |
300 | matz | 299 | matz |
| 300 | .br |
301 | %·ruby·-p·-i.bak·-e·'$_.upcase!'·/tmp/junk | 301 | %·ruby·-p·-i.bak·-e·'$_.upcase!'·/tmp/junk |
| 302 | .br |
302 | %·cat·/tmp/junk | 303 | %·cat·/tmp/junk |
| 304 | .br |
303 | MATZ | 305 | MATZ |
| 306 | .br |
304 | %·cat·/tmp/junk.bak | 307 | %·cat·/tmp/junk.bak |
| 308 | .br |
305 | matz | 309 | matz |
306 | .Ed | |
307 | .Pp | |
308 | .It·Fl·l | 310 | .br |
| |
| 311 | .TP |
| 312 | \fB\-l\fP |
309 | (The·lowercase·letter | 313 | (The·lowercase·letter |
310 | .Dq·ell·.·) | 314 | ``ell''.) |
311 | Enables·automatic·line-ending·processing,·which·means·to·firstly·set | 315 | Enables·automatic·line-ending·processing,·which·means·to·firstly·set |
312 | .Li·"$\e" | 316 | "$\e" |
313 | to·the·value·of | 317 | to·the·value·of |
314 | .Li·"$/"·, | 318 | "$/", |
315 | and·secondly·chops·every·line·read·using | 319 | and·secondly·chops·every·line·read·using |
316 | .Li·chomp!·. | |
317 | .Pp | |
318 | .It·Fl·n | 320 | chomp!. |
| |
| 321 | .TP |
| 322 | \fB\-n\fP |
319 | Causes·Ruby·to·assume·the·following·loop·around·your·script,·which | 323 | Causes·Ruby·to·assume·the·following·loop·around·your·script,·which |
320 | makes·it·iterate·over·file·name·arguments·somewhat·like | 324 | makes·it·iterate·over·file·name·arguments·somewhat·like |
321 | .Nm·sed | |
322 | .Fl·n | 325 | \fBsed\fP |
| 326 | \fB\-n\fP |
323 | or | 327 | or |
324 | .Nm·awk·. | |
325 | .Bd·-literal·-offset·indent | 328 | \fBawk\fP. |
| |
326 | while·gets | 329 | while·gets |
| 330 | .br |
327 | ··... | 331 | ··... |
| 332 | .br |
328 | end | 333 | end |
329 | .Ed | |
330 | .Pp | |
331 | .It·Fl·p | 334 | .br |
| |
| 335 | .TP |
| 336 | \fB\-p\fP |
332 | Acts·mostly·same·as·-n·switch,·but·print·the·value·of·variable | 337 | Acts·mostly·same·as·-n·switch,·but·print·the·value·of·variable |
333 | .Li·"$_" | 338 | "$_" |
334 | at·the·each·end·of·the·loop.··For·example: | 339 | at·the·each·end·of·the·loop.··For·example: |
335 | .Bd·-literal·-offset·indent | |
336 | %·echo·matz·|·ruby·-p·-e·'$_.tr!·"a-z",·"A-Z"' | 340 | %·echo·matz·|·ruby·-p·-e·'$_.tr!·"a-z",·"A-Z"' |
| 341 | .br |
337 | MATZ | 342 | MATZ |
338 | .Ed | |
339 | .Pp | |
340 | .It·Fl·r·Ar·library | 343 | .br |
| |
| 344 | .TP |
| 345 | \fB\-r\fP·\fIlibrary\fP |
341 | Causes·Ruby·to·load·the·library·using·require.··It·is·useful·when·using | 346 | Causes·Ruby·to·load·the·library·using·require.··It·is·useful·when·using |
342 | .Fl·n | 347 | \fB\-n\fP |
343 | or | 348 | or |
344 | .Fl·p·. | |
345 | .Pp | |
346 | .It·Fl·s | 349 | \fB\-p\fP. |
| |
| 350 | .TP |
| 351 | \fB\-s\fP |
347 | Enables·some·switch·parsing·for·switches·after·script·name·but·before | 352 | Enables·some·switch·parsing·for·switches·after·script·name·but·before |
348 | any·file·name·arguments·(or·before·a | 353 | any·file·name·arguments·(or·before·a |
349 | .Fl·-·)·. | 354 | \fB\--\fP). |
350 | Any·switches·found·there·are·removed·from | 355 | Any·switches·found·there·are·removed·from |
351 | .Li·ARGV | 356 | ARGV |
352 | and·set·the·corresponding·variable·in·the·script.··For·example: | 357 | and·set·the·corresponding·variable·in·the·script.··For·example: |
353 | .Bd·-literal·-offset·indent | |
354 | #!·/usr/local/bin/ruby·-s | 358 | #!·/usr/local/bin/ruby·-s |
| 359 | .br |
355 | #·prints·"true"·if·invoked·with·`-xyz'·switch. | 360 | #·prints·"true"·if·invoked·with·`-xyz'·switch. |
| 361 | .br |
356 | print·"true\en"·if·$xyz | 362 | print·"true\en"·if·$xyz |
357 | .Ed | |
358 | .Pp | |
359 | .It·Fl·v | 363 | .br |
| |
| 364 | .TP |
| 365 | \fB\-v\fP |
360 | Enables·verbose·mode.··Ruby·will·print·its·version·at·the·beginning | 366 | Enables·verbose·mode.··Ruby·will·print·its·version·at·the·beginning |
361 | and·set·the·variable | 367 | and·set·the·variable |
362 | .Li·"$VERBOSE" | 368 | "$VERBOSE" |
363 | to·true.··Some·methods·print·extra·messages·if·this·variable·is·true. | 369 | to·true.··Some·methods·print·extra·messages·if·this·variable·is·true. |
364 | If·this·switch·is·given,·and·no·other·switches·are·present,·Ruby·quits | 370 | If·this·switch·is·given,·and·no·other·switches·are·present,·Ruby·quits |
365 | after·printing·its·version. | 371 | after·printing·its·version. |
366 | .Pp | |
367 | .It·Fl·w | |
| 372 | .TP |
| 373 | \fB\-w\fP |
368 | Enables·verbose·mode·without·printing·version·message·at·the | 374 | Enables·verbose·mode·without·printing·version·message·at·the |
369 | beginning.··It·sets·the | 375 | beginning.··It·sets·the |
370 | .Li·"$VERBOSE" | 376 | "$VERBOSE" |
371 | variable·to·true. | 377 | variable·to·true. |
372 | .Pp | |
373 | .It·Fl·x·Ns·Op·Ar·directory | |
| 378 | .TP |
| 379 | \fB\-x\fP[\fIdirectory\fP] |
374 | Tells·Ruby·that·the·script·is·embedded·in·a·message.··Leading·garbage | 380 | Tells·Ruby·that·the·script·is·embedded·in·a·message.··Leading·garbage |
375 | will·be·discarded·until·the·first·line·that·starts·with | 381 | will·be·discarded·until·the·first·line·that·starts·with |
376 | .Dq·#! | 382 | ``#!'' |
377 | and·contains·the·string, | 383 | and·contains·the·string, |
378 | .Dq·ruby·. | 384 | ``ruby''. |
379 | Any·meaningful·switches·on·that·line·will·be·applied.··The·end·of·the·script | 385 | Any·meaningful·switches·on·that·line·will·be·applied.··The·end·of·the·script |
380 | must·be·specified·with·either | 386 | must·be·specified·with·either |
381 | .Li·EOF·, | 387 | EOF, |
382 | .Li·"^D"·(·Li·"control-D"·)·, | 388 | "^D"·("control-D"), |
383 | .Li·"^Z"·(·Li·"control-Z"·)·, | 389 | "^Z"·("control-Z"), |
384 | or·the·reserved·word | 390 | or·the·reserved·word |
385 | .Li·__END__·. | 391 | __END__. |
386 | If·the·directory·name·is·specified,·Ruby·will·switch·to·that·directory | 392 | If·the·directory·name·is·specified,·Ruby·will·switch·to·that·directory |
387 | before·executing·script. | 393 | before·executing·script. |
388 | .Pp | |
389 | .It·Fl·y | |
390 | .It·Fl·-yydebug | |
| 394 | .TP |
| 395 | \fB\-y\fP |
| 396 | .TP |
| 397 | \fB\--yydebug\fP |
391 | DO·NOT·USE. | 398 | DO·NOT·USE. |
392 | .Pp | |
393 | Turns·on·compiler·debug·mode.··Ruby·will·print·a·bunch·of·internal | 399 | Turns·on·compiler·debug·mode.··Ruby·will·print·a·bunch·of·internal |
394 | state·messages·during·compilation.··Only·specify·this·switch·you·are·going·to | 400 | state·messages·during·compilation.··Only·specify·this·switch·you·are·going·to |
395 | debug·the·Ruby·interpreter. | 401 | debug·the·Ruby·interpreter. |
396 | .Pp | |
397 | .It·Fl·-disable-·Ns·Ar·FEATURE | |
398 | .It·Fl·-enable-·Ns·Ar·FEATURE | |
| 402 | .TP |
| 403 | \fB\--disable-\fP\fIFEATURE\fP |
| 404 | .TP |
| 405 | \fB\--enable-\fP\fIFEATURE\fP |
399 | Disables·(or·enables)·the·specified | 406 | Disables·(or·enables)·the·specified |
400 | .Ar·FEATURE·. | |
401 | .Bl·-tag·-width·"--disable-rubyopt"·-compact | |
402 | .It·Fl·-disable-gems | |
403 | .It·Fl·-enable-gems | 407 | \fIFEATURE\fP. |
| 408 | .TP |
| 409 | \fB\--disable-gems\fP |
| 410 | .TP |
| 411 | \fB\--enable-gems\fP |
404 | Disables·(or·enables)·RubyGems·libraries.··By·default,·Ruby·will·load·the·latest | 412 | Disables·(or·enables)·RubyGems·libraries.··By·default,·Ruby·will·load·the·latest |
405 | version·of·each·installed·gem.·The | 413 | version·of·each·installed·gem.·The |
406 | .Li·Gem | 414 | Gem |
407 | constant·is·true·if·RubyGems·is·enabled,·false·if·otherwise. | 415 | constant·is·true·if·RubyGems·is·enabled,·false·if·otherwise. |
408 | .Pp | |
409 | .It·Fl·-disable-rubyopt | |
410 | .It·Fl·-enable-rubyopt | |
| 416 | .TP |
| 417 | \fB\--disable-rubyopt\fP |
| 418 | .TP |
| 419 | \fB\--enable-rubyopt\fP |
411 | Ignores·(or·considers)·the | 420 | Ignores·(or·considers)·the |
412 | .Ev·RUBYOPT | 421 | .IR·RUBYOPT |
413 | environment·variable.·By·default,·Ruby·considers·the·variable. | 422 | environment·variable.·By·default,·Ruby·considers·the·variable. |
414 | .Pp | |
415 | .It·Fl·-disable-all | |
416 | .It·Fl·-enable-all | |
| 423 | .TP |
| 424 | \fB\--disable-all\fP |
| 425 | .TP |
| 426 | \fB\--enable-all\fP |
417 | Disables·(or·enables)·all·features. | 427 | Disables·(or·enables)·all·features. |
418 | .Pp | |
419 | .El | |
420 | .Pp | |
421 | .It·Fl·-dump·Ns·=·Ns·Ar·target | |
| |
| 428 | .TP |
| 429 | \fB\--dump\fP=\fItarget\fP |
422 | Dump·some·information. | 430 | Dump·some·information. |
423 | .Pp | |
424 | Prints·the·specified·target. | 431 | Prints·the·specified·target. |
425 | .Ar·target | 432 | \fItarget\fP |
426 | can·be·one·of: | 433 | can·be·one·of: |
427 | .Bl·-hang·-offset·indent | 434 | .TP |
428 | .It·Sy·version | 435 | .B·version |
429 | Print·version·description·(same·as | 436 | Print·version·description·(same·as |
430 | .Fl·-version). | |
431 | .It·Sy·usage | 437 | \fB\--version).\fP |
| 438 | .TP |
| 439 | .B·usage |
432 | Print·a·brief·usage·message·(same·as | 440 | Print·a·brief·usage·message·(same·as |
433 | .Fl·h). | |
434 | .It·Sy·help | 441 | \fB\-h).\fP |
| 442 | .TP |
| 443 | .B·help |
435 | Show·long·help·message·(same·as | 444 | Show·long·help·message·(same·as |
436 | .Fl·-help). | |
437 | .It·Sy·syntax | 445 | \fB\--help).\fP |
| 446 | .TP |
| 447 | .B·syntax |
438 | Check·syntax·(same·as | 448 | Check·syntax·(same·as |
| 449 | \fB\-c\fP |
| 450 | \fB\--yydebug).\fP |
| |
| |
439 | .Fl·c | |
440 | .Fl·-yydebug). | |
441 | .Pp | |
442 | .El | |
443 | .Pp | |
444 | Or·one·of·the·following,·which·are·intended·for·debugging·the·interpreter: | 451 | Or·one·of·the·following,·which·are·intended·for·debugging·the·interpreter: |
445 | .Bl·-hang·-offset·indent·-tag·-width·"parsetree_with_comment" | 452 | .TP |
446 | .It·Sy·yydebug | 453 | .B·yydebug |
447 | Enable·compiler·debug·mode·(same·as | 454 | Enable·compiler·debug·mode·(same·as |
448 | .Fl·-yydebug). | 455 | \fB\--yydebug).\fP |
| 456 | .TP |
449 | .It·Sy·parsetree | 457 | .B·parsetree |
450 | Print·a·textual·representation·of·the·Ruby·AST·for·the·program. | 458 | Print·a·textual·representation·of·the·Ruby·AST·for·the·program. |
| 459 | .TP |
451 | .It·Sy·parsetree_with_comment | 460 | .B·parsetree_with_comment |
452 | Print·a·textual·representation·of·the·Ruby·AST·for·the·program,·but·with·each·node·annoted·with·the·associated·Ruby·source·code. | 461 | Print·a·textual·representation·of·the·Ruby·AST·for·the·program,·but·with·each·node·annoted·with·the·associated·Ruby·source·code. |
453 | .It·Sy·insns | 462 | .TP |
| 463 | .B·insns |
454 | Print·a·list·of·disassembled·bytecode·instructions. | 464 | Print·a·list·of·disassembled·bytecode·instructions. |
| 465 | .TP |
455 | .It·Sy·insns_without_opt | 466 | .B·insns_without_opt |
456 | Print·the·list·of·disassembled·bytecode·instructions·before·various·optimizations·have·been·applied. | 467 | Print·the·list·of·disassembled·bytecode·instructions·before·various·optimizations·have·been·applied. |
457 | .El | |
458 | .Pp | |
459 | .It·Fl·-verbose | |
| 468 | .TP |
| 469 | \fB\--verbose\fP |
460 | Enables·verbose·mode·without·printing·version·message·at·the | 470 | Enables·verbose·mode·without·printing·version·message·at·the |
461 | beginning.··It·sets·the | 471 | beginning.··It·sets·the |
462 | .Li·"$VERBOSE" | 472 | "$VERBOSE" |
463 | variable·to·true. | 473 | variable·to·true. |
464 | If·this·switch·is·given,·and·no·script·arguments·(script·file·or | 474 | If·this·switch·is·given,·and·no·script·arguments·(script·file·or |
465 | .Fl·e | 475 | \fB\-e\fP |
466 | options)·are·present,·Ruby·quits·immediately. | 476 | options)·are·present,·Ruby·quits·immediately. |
| |
467 | .El | |
468 | .Pp | |
469 | .Sh·ENVIRONMENT | 477 | .SH·ENVIRONMENT |
470 | .Bl·-tag·-width·"RUBYSHELL"·-compact | 478 | .TP |
471 | .It·Ev·RUBYLIB | 479 | .B·RUBYLIB |
472 | A·colon-separated·list·of·directories·that·are·added·to·Ruby's | 480 | A·colon-separated·list·of·directories·that·are·added·to·Ruby's |
473 | library·load·path | 481 | library·load·path |
474 | .Pf·(·Li·"$:"·)·.·Directories·from·this·environment·variable·are·searched | 482 | ("$:").·Directories·from·this·environment·variable·are·searched |
475 | before·the·standard·load·path·is·searched. | 483 | before·the·standard·load·path·is·searched. |
476 | .Pp | |
477 | e.g.: | 484 | e.g.: |
| 485 | .nf |
478 | .Dl·RUBYLIB="$HOME/lib/ruby:$HOME/lib/rubyext" | 486 | \&··RUBYLIB="$HOME/lib/ruby:$HOME/lib/rubyext" |
479 | .Pp | 487 | .fi |
| |
| 488 | .TP |
480 | .It·Ev·RUBYOPT | 489 | .B·RUBYOPT |
481 | Additional·Ruby·options. | 490 | Additional·Ruby·options. |
482 | .Pp | |
483 | e.g. | 491 | e.g. |
| 492 | .nf |
484 | .Dl·RUBYOPT="-w·-Ke" | 493 | \&··RUBYOPT="-w·-Ke" |
485 | .Pp | 494 | .fi |
| |
486 | Note·that·RUBYOPT·can·contain·only | 495 | Note·that·RUBYOPT·can·contain·only |
487 | .Fl·d·,·Fl·E·,·Fl·I·,·Fl·K·,·Fl·r·,·Fl·T·,·Fl·U·,·Fl·v·,·Fl·w·,·Fl·W,·Fl·-debug·, | |
488 | .Fl·-disable-·Ns·Ar·FEATURE | 496 | \fB\-d\fP,\fB\-E\fP,\fB\-I\fP,\fB\-K\fP,\fB\-r\fP,\fB\-T\fP,\fB\-U\fP,\fB\-v\fP,\fB\-w\fP,\fB\-W,\fP·\fB\--debug\fP, |
| 497 | \fB\--disable-\fP\fIFEATURE\fP |
489 | and | 498 | and |
490 | .Fl·-enable-·Ns·Ar·FEATURE·. | |
491 | .Pp | 499 | \fB\--enable-\fP\fIFEATURE\fP. |
| |
| 500 | .TP |
492 | .It·Ev·RUBYPATH | 501 | .B·RUBYPATH |
493 | A·colon-separated·list·of·directories·that·Ruby·searches·for | 502 | A·colon-separated·list·of·directories·that·Ruby·searches·for |
494 | Ruby·programs·when·the | 503 | Ruby·programs·when·the |
495 | .Fl·S | 504 | \fB\-S\fP |
496 | flag·is·specified.··This·variable·precedes·the | 505 | flag·is·specified.··This·variable·precedes·the |
497 | .Ev·PATH | 506 | .IR·PATH |
498 | environment·variable. | 507 | environment·variable. |
499 | .Pp | |
| 508 | .TP |
500 | .It·Ev·RUBYSHELL | 509 | .B·RUBYSHELL |
501 | The·path·to·the·system·shell·command.··This·environment·variable·is | 510 | The·path·to·the·system·shell·command.··This·environment·variable·is |
502 | enabled·for·only·mswin32,·mingw32,·and·OS/2·platforms.··If·this | 511 | enabled·for·only·mswin32,·mingw32,·and·OS/2·platforms.··If·this |
503 | variable·is·not·defined,·Ruby·refers·to | 512 | variable·is·not·defined,·Ruby·refers·to |
504 | .Ev·COMSPEC·. | 513 | .IR·COMSPEC. |
505 | .Pp | |
506 | .It·Ev·PATH | |
| 514 | .TP |
| 515 | .B·PATH |
507 | Ruby·refers·to·the | 516 | Ruby·refers·to·the |
508 | .Ev·PATH | 517 | .IR·PATH |
509 | environment·variable·on·calling·Kernel#system. | 518 | environment·variable·on·calling·Kernel#system. |
| |
510 | .El | |
511 | .Pp | |
512 | And·Ruby·depends·on·some·RubyGems·related·environment·variables·unless·RubyGems·is·disabled. | 519 | And·Ruby·depends·on·some·RubyGems·related·environment·variables·unless·RubyGems·is·disabled. |
513 | See·the·help·of | 520 | See·the·help·of |
514 | .Xr·gem·1 | 521 | \fBgem\fP(1) |
515 | as·below. | 522 | as·below. |
516 | .Bd·-literal·-offset·indent | |
517 | %·gem·help | 523 | %·gem·help |
518 | .Ed | |
519 | .Pp | 524 | .br |
| |
520 | .Sh·GC·ENVIRONMENT | 525 | .SH·GC·ENVIRONMENT |
521 | The·Ruby·garbage·collector·(GC)·tracks·objects·in·fixed-sized·slots, | 526 | The·Ruby·garbage·collector·(GC)·tracks·objects·in·fixed-sized·slots, |
522 | but·each·object·may·have·auxiliary·memory·allocations·handled·by·the | 527 | but·each·object·may·have·auxiliary·memory·allocations·handled·by·the |
523 | malloc·family·of·C·standard·library·calls·( | 528 | malloc·family·of·C·standard·library·calls·( |
524 | .Xr·malloc·3·, | |
525 | .Xr·calloc·3·, | 529 | \fBmalloc\fP(3), |
| 530 | \fBcalloc\fP(3), |
526 | and | 531 | and |
527 | .Xr·realloc·3·)·. | 532 | \fBrealloc\fP(3)) |
528 | In·this·documentatation,·the·"heap"·refers·to·the·Ruby·object·heap | 533 | In·this·documentatation,·the·"heap"·refers·to·the·Ruby·object·heap |
529 | of·fixed-sized·slots,·while·"malloc"·refers·to·auxiliary | 534 | of·fixed-sized·slots,·while·"malloc"·refers·to·auxiliary |
530 | allocations·commonly·referred·to·as·the·"process·heap". | 535 | allocations·commonly·referred·to·as·the·"process·heap". |
531 | Thus·there·are·at·least·two·possible·ways·to·trigger·GC: | 536 | Thus·there·are·at·least·two·possible·ways·to·trigger·GC: |
532 | .Bl·-hang·-offset·indent | |
533 | .It·Sy·1 | 537 | .TP |
| 538 | .B·1 |
534 | Reaching·the·object·limit. | 539 | Reaching·the·object·limit. |
535 | .It·Sy·2 | 540 | .TP |
| 541 | .B·2 |
536 | Reaching·the·malloc·limit. | 542 | Reaching·the·malloc·limit. |
| |
537 | .Pp | |
538 | .El | |
539 | In·Ruby·2.1,·the·generational·GC·was·introduced·and·the·limits·are·divided | 543 | In·Ruby·2.1,·the·generational·GC·was·introduced·and·the·limits·are·divided |
540 | into·young·and·old·generations,·providing·two·additional·ways·to·trigger | 544 | into·young·and·old·generations,·providing·two·additional·ways·to·trigger |
541 | a·GC: | 545 | a·GC: |
542 | .Bl·-hang·-offset·indent | |
543 | .It·Sy·3 | 546 | .TP |
| 547 | .B·3 |
544 | Reaching·the·old·object·limit. | 548 | Reaching·the·old·object·limit. |
545 | .It·Sy·4 | 549 | .TP |
| 550 | .B·4 |
546 | Reaching·the·old·malloc·limit. | 551 | Reaching·the·old·malloc·limit. |
| |
547 | .El | |
548 | .Pp | |
549 | There·are·currently·4·possible·areas·where·the·GC·may·be·tuned·by | 552 | There·are·currently·4·possible·areas·where·the·GC·may·be·tuned·by |
550 | the·following·11·environment·variables: | 553 | the·following·11·environment·variables: |
551 | .Bl·-hang·-compact·-width·"RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR" | 554 | .TP |
552 | .It·Ev·RUBY_GC_HEAP_INIT_SLOTS | 555 | .B·RUBY_GC_HEAP_INIT_SLOTS |
553 | Initial·allocation·slots.··Introduced·in·Ruby·2.1,·default:·10000. | 556 | Initial·allocation·slots.··Introduced·in·Ruby·2.1,·default:·10000. |
554 | .Pp | |
| 557 | .TP |
555 | .It·Ev·RUBY_GC_HEAP_FREE_SLOTS | 558 | .B·RUBY_GC_HEAP_FREE_SLOTS |
556 | Prepare·at·least·this·amount·of·slots·after·GC. | 559 | Prepare·at·least·this·amount·of·slots·after·GC. |
557 | Allocate·this·number·slots·if·there·are·not·enough·slots. | 560 | Allocate·this·number·slots·if·there·are·not·enough·slots. |
558 | Introduced·in·Ruby·2.1,·default:·4096 | 561 | Introduced·in·Ruby·2.1,·default:·4096 |
559 | .Pp | |
| 562 | .TP |
560 | .It·Ev·RUBY_GC_HEAP_GROWTH_FACTOR | 563 | .B·RUBY_GC_HEAP_GROWTH_FACTOR |
561 | Increase·allocation·rate·of·heap·slots·by·this·factor. | 564 | Increase·allocation·rate·of·heap·slots·by·this·factor. |
562 | Introduced·in·Ruby·2.1,·default:·1.8,·minimum:·1.0·(no·growth) | 565 | Introduced·in·Ruby·2.1,·default:·1.8,·minimum:·1.0·(no·growth) |
563 | .Pp | |
| 566 | .TP |
564 | .It·Ev·RUBY_GC_HEAP_GROWTH_MAX_SLOTS | 567 | .B·RUBY_GC_HEAP_GROWTH_MAX_SLOTS |
565 | Allocation·rate·is·limited·to·this·number·of·slots, | 568 | Allocation·rate·is·limited·to·this·number·of·slots, |
566 | preventing·excessive·allocation·due·to·RUBY_GC_HEAP_GROWTH_FACTOR. | 569 | preventing·excessive·allocation·due·to·RUBY_GC_HEAP_GROWTH_FACTOR. |
567 | Introduced·in·Ruby·2.1,·default:·0·(no·limit) | 570 | Introduced·in·Ruby·2.1,·default:·0·(no·limit) |
568 | .Pp | |
| 571 | .TP |
569 | .It·Ev·RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR | 572 | .B·RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR |
570 | Perform·a·full·GC·when·the·number·of·old·objects·is·more·than·R·*·N, | 573 | Perform·a·full·GC·when·the·number·of·old·objects·is·more·than·R·*·N, |
571 | where·R·is·this·factor·and·N·is·the·number·of·old·objects·after·the | 574 | where·R·is·this·factor·and·N·is·the·number·of·old·objects·after·the |
572 | last·full·GC. | 575 | last·full·GC. |
573 | Introduced·in·Ruby·2.1.1,·default:·2.0 | 576 | Introduced·in·Ruby·2.1.1,·default:·2.0 |
574 | .Pp | |
| 577 | .TP |
575 | .It·Ev·RUBY_GC_MALLOC_LIMIT | 578 | .B·RUBY_GC_MALLOC_LIMIT |
576 | The·initial·limit·of·young·generation·allocation·from·the·malloc-family. | 579 | The·initial·limit·of·young·generation·allocation·from·the·malloc-family. |
577 | GC·will·start·when·this·limit·is·reached. | 580 | GC·will·start·when·this·limit·is·reached. |
578 | Default:·16MB | 581 | Default:·16MB |
579 | .Pp | |
| 582 | .TP |
580 | .It·Ev·RUBY_GC_MALLOC_LIMIT_MAX | 583 | .B·RUBY_GC_MALLOC_LIMIT_MAX |
581 | The·maximum·limit·of·young·generation·allocation·from·malloc·before·GC·starts. | 584 | The·maximum·limit·of·young·generation·allocation·from·malloc·before·GC·starts. |
582 | Prevents·excessive·malloc·growth·due·to·RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR. | 585 | Prevents·excessive·malloc·growth·due·to·RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR. |
583 | Introduced·in·Ruby·2.1,·default:·32MB. | 586 | Introduced·in·Ruby·2.1,·default:·32MB. |
584 | .Pp | |
| 587 | .TP |
585 | .It·Ev·RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR | 588 | .B·RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR |
586 | Increases·the·limit·of·young·generation·malloc·calls,·reducing | 589 | Increases·the·limit·of·young·generation·malloc·calls,·reducing |
587 | GC·frequency·but·increasing·malloc·growth·until·RUBY_GC_MALLOC_LIMIT_MAX | 590 | GC·frequency·but·increasing·malloc·growth·until·RUBY_GC_MALLOC_LIMIT_MAX |
588 | is·reached. | 591 | is·reached. |
589 | Introduced·in·Ruby·2.1,·default:·1.4,·minimum:·1.0·(no·growth) | 592 | Introduced·in·Ruby·2.1,·default:·1.4,·minimum:·1.0·(no·growth) |
590 | .Pp | |
| 593 | .TP |
591 | .It·Ev·RUBY_GC_OLDMALLOC_LIMIT | 594 | .B·RUBY_GC_OLDMALLOC_LIMIT |
592 | The·initial·limit·of·old·generation·allocation·from·malloc, | 595 | The·initial·limit·of·old·generation·allocation·from·malloc, |
593 | a·full·GC·will·start·when·this·limit·is·reached. | 596 | a·full·GC·will·start·when·this·limit·is·reached. |
594 | Introduced·in·Ruby·2.1,·default:·16MB | 597 | Introduced·in·Ruby·2.1,·default:·16MB |
595 | .Pp | |
| 598 | .TP |
596 | .It·Ev·RUBY_GC_OLDMALLOC_LIMIT_MAX | 599 | .B·RUBY_GC_OLDMALLOC_LIMIT_MAX |
597 | The·maximum·limit·of·old·generation·allocation·from·malloc·before·a | 600 | The·maximum·limit·of·old·generation·allocation·from·malloc·before·a |
598 | full·GC·starts. | 601 | full·GC·starts. |
599 | Prevents·excessive·malloc·growth·due·to·RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR. | 602 | Prevents·excessive·malloc·growth·due·to·RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR. |
600 | Introduced·in·Ruby·2.1,·default:·128MB | 603 | Introduced·in·Ruby·2.1,·default:·128MB |
601 | .Pp | |
| 604 | .TP |
602 | .It·Ev·RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR | 605 | .B·RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR |
603 | Increases·the·limit·of·old·generation·malloc·allocation,·reducing·full | 606 | Increases·the·limit·of·old·generation·malloc·allocation,·reducing·full |
604 | GC·frequency·but·increasing·malloc·growth·until·RUBY_GC_OLDMALLOC_LIMIT_MAX | 607 | GC·frequency·but·increasing·malloc·growth·until·RUBY_GC_OLDMALLOC_LIMIT_MAX |
605 | is·reached. | 608 | is·reached. |
606 | Introduced·in·Ruby·2.1,·default:·1.2,·minimum:·1.0·(no·growth) | 609 | Introduced·in·Ruby·2.1,·default:·1.2,·minimum:·1.0·(no·growth) |
| |
607 | .Pp | |
608 | .El | |
609 | .Sh·STACK·SIZE·ENVIRONMENT | 610 | .SH·STACK·SIZE·ENVIRONMENT |
610 | Stack·size·environment·variables·are·implementation-dependent·and | 611 | Stack·size·environment·variables·are·implementation-dependent·and |
611 | subject·to·change·with·different·versions·of·Ruby.··The·VM·stack·is·used | 612 | subject·to·change·with·different·versions·of·Ruby.··The·VM·stack·is·used |
612 | for·pure-Ruby·code·and·managed·by·the·virtual·machine.··Machine·stack·is | 613 | for·pure-Ruby·code·and·managed·by·the·virtual·machine.··Machine·stack·is |
613 | used·by·the·operating·system·and·its·usage·is·dependent·on·C·extensions | 614 | used·by·the·operating·system·and·its·usage·is·dependent·on·C·extensions |
614 | as·well·as·C·compiler·options.··Using·lower·values·for·these·may·allow | 615 | as·well·as·C·compiler·options.··Using·lower·values·for·these·may·allow |
615 | applications·to·keep·more·Fibers·or·Threads·running;·but·increases·the | 616 | applications·to·keep·more·Fibers·or·Threads·running;·but·increases·the |
616 | chance·of·SystemStackError·exceptions·and·segmentation·faults·(SIGSEGV). | 617 | chance·of·SystemStackError·exceptions·and·segmentation·faults·(SIGSEGV). |
617 | These·environment·variables·are·available·since·Ruby·2.0.0. | 618 | These·environment·variables·are·available·since·Ruby·2.0.0. |
618 | All·values·are·specified·in·bytes. | 619 | All·values·are·specified·in·bytes. |
619 | .Pp | |
620 | .Bl·-hang·-compact·-width·"RUBY_THREAD_MACHINE_STACK_SIZE" | |
| 620 | .TP |
621 | .It·Ev·RUBY_THREAD_VM_STACK_SIZE | 621 | .B·RUBY_THREAD_VM_STACK_SIZE |
622 | VM·stack·size·used·at·thread·creation. | 622 | VM·stack·size·used·at·thread·creation. |
623 | default:·524288·(32-bit·CPU)·or·1048575·(64-bit) | 623 | default:·524288·(32-bit·CPU)·or·1048575·(64-bit) |
624 | .Pp | |
| 624 | .TP |
625 | .It·Ev·RUBY_THREAD_MACHINE_STACK_SIZE | 625 | .B·RUBY_THREAD_MACHINE_STACK_SIZE |
626 | Machine·stack·size·used·at·thread·creation. | 626 | Machine·stack·size·used·at·thread·creation. |
627 | default:·524288·or·1048575 | 627 | default:·524288·or·1048575 |
628 | .Pp | |
| 628 | .TP |
629 | .It·Ev·RUBY_FIBER_VM_STACK_SIZE | 629 | .B·RUBY_FIBER_VM_STACK_SIZE |
630 | VM·stack·size·used·at·fiber·creation. | 630 | VM·stack·size·used·at·fiber·creation. |
631 | default:·65536·or·131072 | 631 | default:·65536·or·131072 |
632 | .Pp | |
| 632 | .TP |
633 | .It·Ev·RUBY_FIBER_MACHINE_STACK_SIZE | 633 | .B·RUBY_FIBER_MACHINE_STACK_SIZE |
634 | Machine·stack·size·used·at·fiber·creation. | 634 | Machine·stack·size·used·at·fiber·creation. |
635 | default:·262144·or·524288 | 635 | default:·262144·or·524288 |
| |
636 | .Pp | |
637 | .El | |
638 | .Sh·SEE·ALSO | 636 | .SH·SEE·ALSO |
639 | .Bl·-hang·-compact·-width·"https://www.ruby-toolbox.com/" | 637 | .TP |
640 | .It·Lk·https://www.ruby-lang.org/ | 638 | .B·https://www.ruby-lang.org/ |
641 | The·official·web·site. | 639 | The·official·web·site. |
| 640 | .TP |
642 | .It·Lk·https://www.ruby-toolbox.com/ | 641 | .B·https://www.ruby-toolbox.com/ |
643 | Comprehensive·catalog·of·Ruby·libraries. | 642 | Comprehensive·catalog·of·Ruby·libraries. |
| |
644 | .El | |
645 | .Pp | |
646 | .Sh·REPORTING·BUGS | 643 | .SH·REPORTING·BUGS |
| 644 | .IP·\(bu |
647 | .Bl·-bullet | |
648 | .It | |
649 | Security·vulnerabilities·should·be·reported·via·an·email·to | 645 | Security·vulnerabilities·should·be·reported·via·an·email·to |
650 | .Mt·security@ruby-lang.org·. | 646 | Mt·security@ruby-lang.org. |
651 | Reported·problems·will·be·published·after·being·fixed. | 647 | Reported·problems·will·be·published·after·being·fixed. |
652 | .Pp | |
653 | .It | |
| 648 | .IP·\(bu |
654 | Other·bugs·and·feature·requests·can·be·reported·via·the | 649 | Other·bugs·and·feature·requests·can·be·reported·via·the |
655 | Ruby·Issue·Tracking·System | 650 | Ruby·Issue·Tracking·System |
656 | .Pq·Lk·https://bugs.ruby-lang.org/·. | 651 | (\fBhttps://bugs.ruby-lang.org/\fP). |
657 | Do·not·report·security·vulnerabilities | 652 | Do·not·report·security·vulnerabilities |
658 | via·this·system·because·it·publishes·the·vulnerabilities·immediately. | 653 | via·this·system·because·it·publishes·the·vulnerabilities·immediately. |
659 | .El | |
660 | .Sh·AUTHORS | 654 | .SH·AUTHORS |
661 | Ruby·is·designed·and·implemented·by | 655 | Ruby·is·designed·and·implemented·by |
662 | .An·Yukihiro·Matsumoto·Aq·matz@netlab.jp·. | 656 | Yukihiro·Matsumoto·<matz@netlab.jp>. |
663 | .Pp | |
664 | See | 657 | See |
665 | .Aq·Lk·https://bugs.ruby-lang.org/projects/ruby/wiki/Contributors | 658 | <\fBhttps://bugs.ruby-lang.org/projects/ruby/wiki/Contributors\fP> |
666 | for·contributors·to·Ruby. | 659 | for·contributors·to·Ruby. |