From 1e7373ef3061a3e0f3010ee580e5d4f80baf2e1a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 5 Dec 2025 13:02:22 +0900 Subject: [PATCH] [DOC] Describe the global variables set by command line options These variables are set by command line options, but it is deprecated to assign them any value other than nil in ruby code. --- doc/language/globals.md | 43 ++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/doc/language/globals.md b/doc/language/globals.md index 221ad17e44..7030cc1bfd 100644 --- a/doc/language/globals.md +++ b/doc/language/globals.md @@ -34,10 +34,10 @@ require 'English' ### Separators -| Variable | English | Contains | -|:--------:|:--------------------------:|--------------------------------------------| -| `$/` | `$INPUT_RECORD_SEPARATOR` | Input record separator; initially newline. | -| `$\` | `$OUTPUT_RECORD_SEPARATOR` | Output record separator; initially `nil`. | +| Variable | English | Contains | +|:-----------:|:--------------------------:|--------------------------------------------| +| `$/`, `$-0` | `$INPUT_RECORD_SEPARATOR` | Input record separator; initially newline. | +| `$\` | `$OUTPUT_RECORD_SEPARATOR` | Output record separator; initially `nil`. | ### Streams @@ -72,12 +72,13 @@ require 'English' ### Other Variables -| Variable | English | Contains | -|:--------:|:-------:|------------------------------------------------| -| `$-a` | | Whether option `-a` was given. | -| `$-i` | | Extension given with command-line option `-i`. | -| `$-l` | | Whether option `-l` was given. | -| `$-p` | | Whether option `-p` was given. | +| Variable | English | Contains | +|:-----------:|:-------:|------------------------------------------------| +| `$-F`, `$;` | | Separator given with command-line option `-F`. | +| `$-a` | | Whether option `-a` was given. | +| `$-i` | | Extension given with command-line option `-i`. | +| `$-l` | | Whether option `-l` was given. | +| `$-p` | | Whether option `-p` was given. | ## Exceptions @@ -174,6 +175,10 @@ No \English. ### `$/` (Input Record Separator) An input record separator, initially newline. +Set by the command-line option `-0`. + +Setting to non-nil value by other than the command-line option is +deprecated. English - `$INPUT_RECORD_SEPARATOR`, `$RS`. @@ -182,6 +187,10 @@ Aliased as `$-0`. ### `$\` (Output Record Separator) An output record separator, initially `nil`. +Copied from `$/` when the command-line option `-l` is given. + +Setting to non-nil value by other than the command-line option is +deprecated. English - `$OUTPUT_RECORD_SEPARATOR`, `$ORS`. @@ -340,6 +349,16 @@ Aliased as `$-v` and `$-w`. ## Other Variables +### `$-F` + +The default field separator in String#split; must be a String or a +Regexp, and can be set with command-line option `-F`. + +Setting to non-nil value by other than the command-line option is +deprecated. + +Aliased as `$;`. + ### `$-a` Whether command-line option `-a` was given; read-only. @@ -365,8 +384,6 @@ Whether command-line option `-p` was given; read-only. ### `$,` -### `$;` - # Pre-Defined Global Constants ## Summary @@ -401,7 +418,7 @@ Whether command-line option `-p` was given; read-only. | Constant | Contains | |:--------:|--------------------------------------------------------------------| -| `DATA` | File containing embedded data (lines following `__END__`, if any). | +| `DATA` | File containing embedded data (lines following `__END__`, if any). | ## Streams