| | | | |
| Offset 1, 664 lines modified | Offset 1, 759 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 | version·description·same·as | 436 | version·description·same·as |
| 430 | .Fl·-version | |
| 431 | .It·Sy·usage | 437 | \fB\--version\fP |
| | 438 | .TP |
| | 439 | .B·usage |
| 432 | brief·usage·message·same·as | 440 | 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·of·syntax·same·as | 448 | check·of·syntax·same·as |
| 439 | .Fl·c | 449 | \fB\-c\fP |
| | 450 | \fB\--yydebug\fP |
| | 451 | .TP |
| 440 | .Fl·-yydebug | 452 | .B·yydebug |
| 441 | .It·Sy·yydebug | |
| 442 | compiler·debug·mode,·same·as | 453 | compiler·debug·mode,·same·as |
| 443 | .Fl·-yydebug | |
| 444 | .Pp | 454 | \fB\--yydebug\fP |
| | |
| 445 | Only·specify·this·switch·if·you·are·going·to·debug·the·Ruby·interpreter. | 455 | Only·specify·this·switch·if·you·are·going·to·debug·the·Ruby·interpreter. |
| | 456 | .TP |
| 446 | .It·Sy·parsetree | 457 | .B·parsetree |
| | 458 | .TP |
| 447 | .It·Sy·parsetree_with_comment | 459 | .B·parsetree_with_comment |
| 448 | AST·nodes·tree | 460 | AST·nodes·tree |
| 449 | .Pp | |
| 450 | Only·specify·this·switch·if·you·are·going·to·debug·the·Ruby·interpreter. | 461 | Only·specify·this·switch·if·you·are·going·to·debug·the·Ruby·interpreter. |
| 451 | .It·Sy·insns | 462 | .TP |
| | 463 | .B·insns |
| 452 | disassembled·instructions | 464 | disassembled·instructions |
| 453 | .Pp | |
| 454 | Only·specify·this·switch·if·you·are·going·to·debug·the·Ruby·interpreter. | 465 | Only·specify·this·switch·if·you·are·going·to·debug·the·Ruby·interpreter. |
| 455 | .El | |
| 456 | .Pp | |
| 457 | .It·Fl·-verbose | |
| | 466 | .TP |
| | 467 | \fB\--verbose\fP |
| 458 | Enables·verbose·mode·without·printing·version·message·at·the | 468 | Enables·verbose·mode·without·printing·version·message·at·the |
| 459 | beginning.··It·sets·the | 469 | beginning.··It·sets·the |
| 460 | .Li·"$VERBOSE" | 470 | "$VERBOSE" |
| 461 | variable·to·true. | 471 | variable·to·true. |
| 462 | If·this·switch·is·given,·and·no·script·arguments·(script·file·or | 472 | If·this·switch·is·given,·and·no·script·arguments·(script·file·or |
| 463 | .Fl·e | 473 | \fB\-e\fP |
| 464 | options)·are·present,·Ruby·quits·immediately. | 474 | options)·are·present,·Ruby·quits·immediately. |
| | |
| 465 | .El | |
| 466 | .Pp | |
| 467 | .Sh·ENVIRONMENT | 475 | .SH·ENVIRONMENT |
| 468 | .Bl·-tag·-width·"RUBYSHELL"·-compact | 476 | .TP |
| 469 | .It·Ev·RUBYLIB | 477 | .B·RUBYLIB |
| 470 | A·colon-separated·list·of·directories·that·are·added·to·Ruby's | 478 | A·colon-separated·list·of·directories·that·are·added·to·Ruby's |
| 471 | library·load·path | 479 | library·load·path |
| 472 | .Pf·(·Li·"$:"·)·.·Directories·from·this·environment·variable·are·searched | 480 | ("$:").·Directories·from·this·environment·variable·are·searched |
| 473 | before·the·standard·load·path·is·searched. | 481 | before·the·standard·load·path·is·searched. |
| 474 | .Pp | |
| 475 | e.g.: | 482 | e.g.: |
| | 483 | .nf |
| 476 | .Dl·RUBYLIB="$HOME/lib/ruby:$HOME/lib/rubyext" | 484 | \&··RUBYLIB="$HOME/lib/ruby:$HOME/lib/rubyext" |
| 477 | .Pp | 485 | .fi |
| | |
| | 486 | .TP |
| 478 | .It·Ev·RUBYOPT | 487 | .B·RUBYOPT |
| 479 | Additional·Ruby·options. | 488 | Additional·Ruby·options. |
| 480 | .Pp | |
| 481 | e.g. | 489 | e.g. |
| | 490 | .nf |
| 482 | .Dl·RUBYOPT="-w·-Ke" | 491 | \&··RUBYOPT="-w·-Ke" |
| 483 | .Pp | 492 | .fi |
| | |
| 484 | Note·that·RUBYOPT·can·contain·only | 493 | Note·that·RUBYOPT·can·contain·only |
| 485 | .Fl·d·,·Fl·E·,·Fl·I·,·Fl·K·,·Fl·r·,·Fl·T·,·Fl·U·,·Fl·v·,·Fl·w·,·Fl·W,·Fl·-debug·, | |
| 486 | .Fl·-disable-·Ns·Ar·FEATURE | 494 | \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, |
| | 495 | \fB\--disable-\fP\fIFEATURE\fP |
| 487 | and | 496 | and |
| 488 | .Fl·-enable-·Ns·Ar·FEATURE·. | |
| 489 | .Pp | 497 | \fB\--enable-\fP\fIFEATURE\fP. |
| | |
| | 498 | .TP |
| 490 | .It·Ev·RUBYPATH | 499 | .B·RUBYPATH |
| 491 | A·colon-separated·list·of·directories·that·Ruby·searches·for | 500 | A·colon-separated·list·of·directories·that·Ruby·searches·for |
| 492 | Ruby·programs·when·the | 501 | Ruby·programs·when·the |
| 493 | .Fl·S | 502 | \fB\-S\fP |
| 494 | flag·is·specified.··This·variable·precedes·the | 503 | flag·is·specified.··This·variable·precedes·the |
| 495 | .Ev·PATH | 504 | .IR·PATH |
| 496 | environment·variable. | 505 | environment·variable. |
| 497 | .Pp | |
| | 506 | .TP |
| 498 | .It·Ev·RUBYSHELL | 507 | .B·RUBYSHELL |
| 499 | The·path·to·the·system·shell·command.··This·environment·variable·is | 508 | The·path·to·the·system·shell·command.··This·environment·variable·is |
| 500 | enabled·for·only·mswin32,·mingw32,·and·OS/2·platforms.··If·this | 509 | enabled·for·only·mswin32,·mingw32,·and·OS/2·platforms.··If·this |
| 501 | variable·is·not·defined,·Ruby·refers·to | 510 | variable·is·not·defined,·Ruby·refers·to |
| 502 | .Ev·COMSPEC·. | 511 | .IR·COMSPEC. |
| 503 | .Pp | |
| 504 | .It·Ev·PATH | |
| | 512 | .TP |
| | 513 | .B·PATH |
| 505 | Ruby·refers·to·the | 514 | Ruby·refers·to·the |
| 506 | .Ev·PATH | 515 | .IR·PATH |
| 507 | environment·variable·on·calling·Kernel#system. | 516 | environment·variable·on·calling·Kernel#system. |
| | |
| 508 | .El | |
| 509 | .Pp | |
| 510 | And·Ruby·depends·on·some·RubyGems·related·environment·variables·unless·RubyGems·is·disabled. | 517 | And·Ruby·depends·on·some·RubyGems·related·environment·variables·unless·RubyGems·is·disabled. |
| 511 | See·the·help·of | 518 | See·the·help·of |
| 512 | .Xr·gem·1 | 519 | \fBgem\fP(1) |
| 513 | as·below. | 520 | as·below. |
| 514 | .Bd·-literal·-offset·indent | |
| 515 | %·gem·help | 521 | %·gem·help |
| 516 | .Ed | |
| 517 | .Pp | 522 | .br |
| | |
| 518 | .Sh·GC·ENVIRONMENT | 523 | .SH·GC·ENVIRONMENT |
| 519 | The·Ruby·garbage·collector·(GC)·tracks·objects·in·fixed-sized·slots, | 524 | The·Ruby·garbage·collector·(GC)·tracks·objects·in·fixed-sized·slots, |
| 520 | but·each·object·may·have·auxiliary·memory·allocations·handled·by·the | 525 | but·each·object·may·have·auxiliary·memory·allocations·handled·by·the |
| 521 | malloc·family·of·C·standard·library·calls·( | 526 | malloc·family·of·C·standard·library·calls·( |
| 522 | .Xr·malloc·3·, | |
| 523 | .Xr·calloc·3·, | 527 | \fBmalloc\fP(3), |
| | 528 | \fBcalloc\fP(3), |
| 524 | and | 529 | and |
| 525 | .Xr·realloc·3·)·. | 530 | \fBrealloc\fP(3)) |
| 526 | In·this·documentatation,·the·"heap"·refers·to·the·Ruby·object·heap | 531 | In·this·documentatation,·the·"heap"·refers·to·the·Ruby·object·heap |
| 527 | of·fixed-sized·slots,·while·"malloc"·refers·to·auxiliary | 532 | of·fixed-sized·slots,·while·"malloc"·refers·to·auxiliary |
| 528 | allocations·commonly·referred·to·as·the·"process·heap". | 533 | allocations·commonly·referred·to·as·the·"process·heap". |
| 529 | Thus·there·are·at·least·two·possible·ways·to·trigger·GC: | 534 | Thus·there·are·at·least·two·possible·ways·to·trigger·GC: |
| 530 | .Bl·-hang·-offset·indent | |
| 531 | .It·Sy·1 | 535 | .TP |
| | 536 | .B·1 |
| 532 | Reaching·the·object·limit. | 537 | Reaching·the·object·limit. |
| 533 | .It·Sy·2 | 538 | .TP |
| | 539 | .B·2 |
| 534 | Reaching·the·malloc·limit. | 540 | Reaching·the·malloc·limit. |
| | |
| 535 | .Pp | |
| 536 | .El | |
| 537 | In·Ruby·2.1,·the·generational·GC·was·introduced·and·the·limits·are·divided | 541 | In·Ruby·2.1,·the·generational·GC·was·introduced·and·the·limits·are·divided |
| 538 | into·young·and·old·generations,·providing·two·additional·ways·to·trigger | 542 | into·young·and·old·generations,·providing·two·additional·ways·to·trigger |
| 539 | a·GC: | 543 | a·GC: |
| 540 | .Bl·-hang·-offset·indent | |
| 541 | .It·Sy·3 | 544 | .TP |
| | 545 | .B·3 |
| 542 | Reaching·the·old·object·limit. | 546 | Reaching·the·old·object·limit. |
| 543 | .It·Sy·4 | 547 | .TP |
| | 548 | .B·4 |
| 544 | Reaching·the·old·malloc·limit. | 549 | Reaching·the·old·malloc·limit. |
| | |
| 545 | .El | |
| 546 | .Pp | |
| 547 | There·are·currently·4·possible·areas·where·the·GC·may·be·tuned·by | 550 | There·are·currently·4·possible·areas·where·the·GC·may·be·tuned·by |
| 548 | the·following·11·environment·variables: | 551 | the·following·11·environment·variables: |
| 549 | .Bl·-hang·-compact·-width·"RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR" | 552 | .TP |
| 550 | .It·Ev·RUBY_GC_HEAP_INIT_SLOTS | 553 | .B·RUBY_GC_HEAP_INIT_SLOTS |
| 551 | Initial·allocation·slots.··Introduced·in·Ruby·2.1,·default:·10000. | 554 | Initial·allocation·slots.··Introduced·in·Ruby·2.1,·default:·10000. |
| 552 | .Pp | |
| | 555 | .TP |
| 553 | .It·Ev·RUBY_GC_HEAP_FREE_SLOTS | 556 | .B·RUBY_GC_HEAP_FREE_SLOTS |
| 554 | Prepare·at·least·this·amount·of·slots·after·GC. | 557 | Prepare·at·least·this·amount·of·slots·after·GC. |
| 555 | Allocate·this·number·slots·if·there·are·not·enough·slots. | 558 | Allocate·this·number·slots·if·there·are·not·enough·slots. |
| 556 | Introduced·in·Ruby·2.1,·default:·4096 | 559 | Introduced·in·Ruby·2.1,·default:·4096 |
| 557 | .Pp | |
| | 560 | .TP |
| 558 | .It·Ev·RUBY_GC_HEAP_GROWTH_FACTOR | 561 | .B·RUBY_GC_HEAP_GROWTH_FACTOR |
| 559 | Increase·allocation·rate·of·heap·slots·by·this·factor. | 562 | Increase·allocation·rate·of·heap·slots·by·this·factor. |
| 560 | Introduced·in·Ruby·2.1,·default:·1.8,·minimum:·1.0·(no·growth) | 563 | Introduced·in·Ruby·2.1,·default:·1.8,·minimum:·1.0·(no·growth) |
| 561 | .Pp | |
| | 564 | .TP |
| 562 | .It·Ev·RUBY_GC_HEAP_GROWTH_MAX_SLOTS | 565 | .B·RUBY_GC_HEAP_GROWTH_MAX_SLOTS |
| 563 | Allocation·rate·is·limited·to·this·number·of·slots, | 566 | Allocation·rate·is·limited·to·this·number·of·slots, |
| 564 | preventing·excessive·allocation·due·to·RUBY_GC_HEAP_GROWTH_FACTOR. | 567 | preventing·excessive·allocation·due·to·RUBY_GC_HEAP_GROWTH_FACTOR. |
| 565 | Introduced·in·Ruby·2.1,·default:·0·(no·limit) | 568 | Introduced·in·Ruby·2.1,·default:·0·(no·limit) |
| 566 | .Pp | |
| | 569 | .TP |
| 567 | .It·Ev·RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR | 570 | .B·RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR |
| 568 | Perform·a·full·GC·when·the·number·of·old·objects·is·more·than·R·*·N, | 571 | Perform·a·full·GC·when·the·number·of·old·objects·is·more·than·R·*·N, |
| 569 | where·R·is·this·factor·and·N·is·the·number·of·old·objects·after·the | 572 | where·R·is·this·factor·and·N·is·the·number·of·old·objects·after·the |
| 570 | last·full·GC. | 573 | last·full·GC. |
| 571 | Introduced·in·Ruby·2.1.1,·default:·2.0 | 574 | Introduced·in·Ruby·2.1.1,·default:·2.0 |
| 572 | .Pp | |
| | 575 | .TP |
| 573 | .It·Ev·RUBY_GC_MALLOC_LIMIT | 576 | .B·RUBY_GC_MALLOC_LIMIT |
| 574 | The·initial·limit·of·young·generation·allocation·from·the·malloc-family. | 577 | The·initial·limit·of·young·generation·allocation·from·the·malloc-family. |
| 575 | GC·will·start·when·this·limit·is·reached. | 578 | GC·will·start·when·this·limit·is·reached. |
| 576 | Default:·16MB | 579 | Default:·16MB |
| 577 | .Pp | |
| | 580 | .TP |
| 578 | .It·Ev·RUBY_GC_MALLOC_LIMIT_MAX | 581 | .B·RUBY_GC_MALLOC_LIMIT_MAX |
| 579 | The·maximum·limit·of·young·generation·allocation·from·malloc·before·GC·starts. | 582 | The·maximum·limit·of·young·generation·allocation·from·malloc·before·GC·starts. |
| 580 | Prevents·excessive·malloc·growth·due·to·RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR. | 583 | Prevents·excessive·malloc·growth·due·to·RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR. |
| 581 | Introduced·in·Ruby·2.1,·default:·32MB. | 584 | Introduced·in·Ruby·2.1,·default:·32MB. |
| 582 | .Pp | |
| | 585 | .TP |
| 583 | .It·Ev·RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR | 586 | .B·RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR |
| 584 | Increases·the·limit·of·young·generation·malloc·calls,·reducing | 587 | Increases·the·limit·of·young·generation·malloc·calls,·reducing |
| 585 | GC·frequency·but·increasing·malloc·growth·until·RUBY_GC_MALLOC_LIMIT_MAX | 588 | GC·frequency·but·increasing·malloc·growth·until·RUBY_GC_MALLOC_LIMIT_MAX |
| 586 | is·reached. | 589 | is·reached. |
| 587 | Introduced·in·Ruby·2.1,·default:·1.4,·minimum:·1.0·(no·growth) | 590 | Introduced·in·Ruby·2.1,·default:·1.4,·minimum:·1.0·(no·growth) |
| 588 | .Pp | |
| | 591 | .TP |
| 589 | .It·Ev·RUBY_GC_OLDMALLOC_LIMIT | 592 | .B·RUBY_GC_OLDMALLOC_LIMIT |
| 590 | The·initial·limit·of·old·generation·allocation·from·malloc, | 593 | The·initial·limit·of·old·generation·allocation·from·malloc, |
| 591 | a·full·GC·will·start·when·this·limit·is·reached. | 594 | a·full·GC·will·start·when·this·limit·is·reached. |
| 592 | Introduced·in·Ruby·2.1,·default:·16MB | 595 | Introduced·in·Ruby·2.1,·default:·16MB |
| 593 | .Pp | |
| | 596 | .TP |
| 594 | .It·Ev·RUBY_GC_OLDMALLOC_LIMIT_MAX | 597 | .B·RUBY_GC_OLDMALLOC_LIMIT_MAX |
| 595 | The·maximum·limit·of·old·generation·allocation·from·malloc·before·a | 598 | The·maximum·limit·of·old·generation·allocation·from·malloc·before·a |
| 596 | full·GC·starts. | 599 | full·GC·starts. |
| 597 | Prevents·excessive·malloc·growth·due·to·RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR. | 600 | Prevents·excessive·malloc·growth·due·to·RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR. |
| 598 | Introduced·in·Ruby·2.1,·default:·128MB | 601 | Introduced·in·Ruby·2.1,·default:·128MB |
| 599 | .Pp | |
| | 602 | .TP |
| 600 | .It·Ev·RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR | 603 | .B·RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR |
| 601 | Increases·the·limit·of·old·generation·malloc·allocation,·reducing·full | 604 | Increases·the·limit·of·old·generation·malloc·allocation,·reducing·full |
| 602 | GC·frequency·but·increasing·malloc·growth·until·RUBY_GC_OLDMALLOC_LIMIT_MAX | 605 | GC·frequency·but·increasing·malloc·growth·until·RUBY_GC_OLDMALLOC_LIMIT_MAX |
| 603 | is·reached. | 606 | is·reached. |
| 604 | Introduced·in·Ruby·2.1,·default:·1.2,·minimum:·1.0·(no·growth) | 607 | Introduced·in·Ruby·2.1,·default:·1.2,·minimum:·1.0·(no·growth) |
| | |
| 605 | .Pp | |
| 606 | .El | |
| 607 | .Sh·STACK·SIZE·ENVIRONMENT | 608 | .SH·STACK·SIZE·ENVIRONMENT |
| 608 | Stack·size·environment·variables·are·implementation-dependent·and | 609 | Stack·size·environment·variables·are·implementation-dependent·and |
| 609 | subject·to·change·with·different·versions·of·Ruby.··The·VM·stack·is·used | 610 | subject·to·change·with·different·versions·of·Ruby.··The·VM·stack·is·used |
| 610 | for·pure-Ruby·code·and·managed·by·the·virtual·machine.··Machine·stack·is | 611 | for·pure-Ruby·code·and·managed·by·the·virtual·machine.··Machine·stack·is |
| 611 | used·by·the·operating·system·and·its·usage·is·dependent·on·C·extensions | 612 | used·by·the·operating·system·and·its·usage·is·dependent·on·C·extensions |
| 612 | as·well·as·C·compiler·options.··Using·lower·values·for·these·may·allow | 613 | as·well·as·C·compiler·options.··Using·lower·values·for·these·may·allow |
| 613 | applications·to·keep·more·Fibers·or·Threads·running;·but·increases·the | 614 | applications·to·keep·more·Fibers·or·Threads·running;·but·increases·the |
| 614 | chance·of·SystemStackError·exceptions·and·segmentation·faults·(SIGSEGV). | 615 | chance·of·SystemStackError·exceptions·and·segmentation·faults·(SIGSEGV). |
| 615 | These·environment·variables·are·available·since·Ruby·2.0.0. | 616 | These·environment·variables·are·available·since·Ruby·2.0.0. |
| 616 | All·values·are·specified·in·bytes. | 617 | All·values·are·specified·in·bytes. |
| 617 | .Pp | |
| 618 | .Bl·-hang·-compact·-width·"RUBY_THREAD_MACHINE_STACK_SIZE" | |
| | 618 | .TP |
| 619 | .It·Ev·RUBY_THREAD_VM_STACK_SIZE | 619 | .B·RUBY_THREAD_VM_STACK_SIZE |
| 620 | VM·stack·size·used·at·thread·creation. | 620 | VM·stack·size·used·at·thread·creation. |
| 621 | default:·524288·(32-bit·CPU)·or·1048575·(64-bit) | 621 | default:·524288·(32-bit·CPU)·or·1048575·(64-bit) |
| 622 | .Pp | |
| | 622 | .TP |
| 623 | .It·Ev·RUBY_THREAD_MACHINE_STACK_SIZE | 623 | .B·RUBY_THREAD_MACHINE_STACK_SIZE |
| 624 | Machine·stack·size·used·at·thread·creation. | 624 | Machine·stack·size·used·at·thread·creation. |
| 625 | default:·524288·or·1048575 | 625 | default:·524288·or·1048575 |
| 626 | .Pp | |
| | 626 | .TP |
| 627 | .It·Ev·RUBY_FIBER_VM_STACK_SIZE | 627 | .B·RUBY_FIBER_VM_STACK_SIZE |
| 628 | VM·stack·size·used·at·fiber·creation. | 628 | VM·stack·size·used·at·fiber·creation. |
| 629 | default:·65536·or·131072 | 629 | default:·65536·or·131072 |
| 630 | .Pp | |
| | 630 | .TP |
| 631 | .It·Ev·RUBY_FIBER_MACHINE_STACK_SIZE | 631 | .B·RUBY_FIBER_MACHINE_STACK_SIZE |
| 632 | Machine·stack·size·used·at·fiber·creation. | 632 | Machine·stack·size·used·at·fiber·creation. |
| 633 | default:·262144·or·524288 | 633 | default:·262144·or·524288 |
| | |
| 634 | .Pp | |
| 635 | .El | |
| 636 | .Sh·SEE·ALSO | 634 | .SH·SEE·ALSO |
| 637 | .Bl·-hang·-compact·-width·"https://www.ruby-toolbox.com/" | 635 | .TP |
| 638 | .It·Lk·https://www.ruby-lang.org/ | 636 | .B·https://www.ruby-lang.org/ |
| 639 | The·official·web·site. | 637 | The·official·web·site. |
| | 638 | .TP |
| 640 | .It·Lk·https://www.ruby-toolbox.com/ | 639 | .B·https://www.ruby-toolbox.com/ |
| 641 | Comprehensive·catalog·of·Ruby·libraries. | 640 | Comprehensive·catalog·of·Ruby·libraries. |
| | |
| 642 | .El | |
| 643 | .Pp | |
| 644 | .Sh·REPORTING·BUGS | 641 | .SH·REPORTING·BUGS |
| | 642 | .IP·\(bu |
| 645 | .Bl·-bullet | |
| 646 | .It | |
| 647 | Security·vulnerabilities·should·be·reported·via·an·email·to | 643 | Security·vulnerabilities·should·be·reported·via·an·email·to |
| 648 | .Mt·security@ruby-lang.org·. | 644 | Mt·security@ruby-lang.org. |
| 649 | Reported·problems·will·be·published·after·being·fixed. | 645 | Reported·problems·will·be·published·after·being·fixed. |
| 650 | .Pp | |
| 651 | .It | |
| | 646 | .IP·\(bu |
| 652 | Other·bugs·and·feature·requests·can·be·reported·via·the | 647 | Other·bugs·and·feature·requests·can·be·reported·via·the |
| 653 | Ruby·Issue·Tracking·System | 648 | Ruby·Issue·Tracking·System |
| 654 | .Pq·Lk·https://bugs.ruby-lang.org/·. | 649 | (\fBhttps://bugs.ruby-lang.org/\fP). |
| 655 | Do·not·report·security·vulnerabilities | 650 | Do·not·report·security·vulnerabilities |
| 656 | via·this·system·because·it·publishes·the·vulnerabilities·immediately. | 651 | via·this·system·because·it·publishes·the·vulnerabilities·immediately. |
| 657 | .El | |
| 658 | .Sh·AUTHORS | 652 | .SH·AUTHORS |
| 659 | Ruby·is·designed·and·implemented·by | 653 | Ruby·is·designed·and·implemented·by |
| 660 | .An·Yukihiro·Matsumoto·Aq·matz@netlab.jp·. | 654 | Yukihiro·Matsumoto·<matz@netlab.jp>. |
| 661 | .Pp | |
| 662 | See | 655 | See |
| 663 | .Aq·Lk·https://bugs.ruby-lang.org/projects/ruby/wiki/Contributors | 656 | <\fBhttps://bugs.ruby-lang.org/projects/ruby/wiki/Contributors\fP> |
| 664 | for·contributors·to·Ruby. | 657 | for·contributors·to·Ruby. |