From 72772a3caa16fd240aa1e9c9432e2d6492c0b0ac Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 16 Sep 2023 11:45:43 +0900 Subject: [PATCH] [DOC] Mention "-" in ARGF --- doc/globals.rdoc | 11 +++++++---- io.c | 9 +++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/globals.rdoc b/doc/globals.rdoc index 556e433dcb..2b4f6bd7cf 100644 --- a/doc/globals.rdoc +++ b/doc/globals.rdoc @@ -269,6 +269,8 @@ Whether command-line option -a was given; read-only. Contains the extension given with command-line option -i, or +nil+ if none. +An alias of ARGF.inplace_mode. + ==== $-l Whether command-line option -l was set; read-only. @@ -307,7 +309,7 @@ The standard error stream (the default value for $stderr): === Enviroment -==== ENV +==== ENV A hash of the contains current environment variables names and values: @@ -319,10 +321,11 @@ A hash of the contains current environment variables names and values: ["DISPLAY", ":0"], ["GDMSESSION", "ubuntu"]] -==== ARGF +==== ARGF -The virtual concatenation of the files given on the command line, -or from $stdin if no files were given. +The virtual concatenation of the files given on the command line, or from +$stdin if no files were given, "-" is given, or after +all files have been read. ==== ARGV diff --git a/io.c b/io.c index 480bed9157..712dce3ceb 100644 --- a/io.c +++ b/io.c @@ -14625,11 +14625,16 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y) * ARGV.replace ["file2", "file3"] * ARGF.read # Returns the contents of file2 and file3 * - * If +ARGV+ is empty, ARGF acts as if it contained STDIN, i.e. the data - * piped to your script. For example: + * If +ARGV+ is empty, ARGF acts as if it contained "-" that + * makes ARGF read from STDIN, i.e. the data piped or typed to your + * script. For example: * * $ echo "glark" | ruby -e 'p ARGF.read' * "glark\n" + * + * $ echo Glark > file1 + * $ echo "glark" | ruby -e 'p ARGF.read' -- - file1 + * "glark\nGlark\n" */ /*