[DOC] Mention "-" in ARGF

This commit is contained in:
Nobuyoshi Nakada 2023-09-16 11:45:43 +09:00
parent 2dffd36504
commit 72772a3caa
2 changed files with 14 additions and 6 deletions

View File

@ -269,6 +269,8 @@ Whether command-line option <tt>-a</tt> was given; read-only.
Contains the extension given with command-line option <tt>-i</tt>, Contains the extension given with command-line option <tt>-i</tt>,
or +nil+ if none. or +nil+ if none.
An alias of ARGF.inplace_mode.
==== <tt>$-l</tt> ==== <tt>$-l</tt>
Whether command-line option <tt>-l</tt> was set; read-only. Whether command-line option <tt>-l</tt> was set; read-only.
@ -307,7 +309,7 @@ The standard error stream (the default value for <tt>$stderr</tt>):
=== Enviroment === Enviroment
==== <tt>ENV</tt> ==== ENV
A hash of the contains current environment variables names and values: 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"], ["DISPLAY", ":0"],
["GDMSESSION", "ubuntu"]] ["GDMSESSION", "ubuntu"]]
==== <tt>ARGF</tt> ==== ARGF
The virtual concatenation of the files given on the command line, The virtual concatenation of the files given on the command line, or from
or from <tt>$stdin</tt> if no files were given. <tt>$stdin</tt> if no files were given, <tt>"-"</tt> is given, or after
all files have been read.
==== <tt>ARGV</tt> ==== <tt>ARGV</tt>

9
io.c
View File

@ -14625,11 +14625,16 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* ARGV.replace ["file2", "file3"] * ARGV.replace ["file2", "file3"]
* ARGF.read # Returns the contents of file2 and 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 * If +ARGV+ is empty, ARGF acts as if it contained <tt>"-"</tt> that
* piped to your script. For example: * makes ARGF read from STDIN, i.e. the data piped or typed to your
* script. For example:
* *
* $ echo "glark" | ruby -e 'p ARGF.read' * $ echo "glark" | ruby -e 'p ARGF.read'
* "glark\n" * "glark\n"
*
* $ echo Glark > file1
* $ echo "glark" | ruby -e 'p ARGF.read' -- - file1
* "glark\nGlark\n"
*/ */
/* /*