Skip to content

Commit

Permalink
[DOC] Mention "-" in ARGF
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Sep 17, 2023
1 parent 2dffd36 commit 72772a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 7 additions & 4 deletions doc/globals.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
or +nil+ if none.

An alias of ARGF.inplace_mode.

==== <tt>$-l</tt>

Whether command-line option <tt>-l</tt> was set; read-only.
Expand Down Expand Up @@ -307,7 +309,7 @@ The standard error stream (the default value for <tt>$stderr</tt>):

=== Enviroment

==== <tt>ENV</tt>
==== ENV

A hash of the contains current environment variables names and values:

Expand All @@ -319,10 +321,11 @@ A hash of the contains current environment variables names and values:
["DISPLAY", ":0"],
["GDMSESSION", "ubuntu"]]

==== <tt>ARGF</tt>
==== ARGF

The virtual concatenation of the files given on the command line,
or from <tt>$stdin</tt> if no files were given.
The virtual concatenation of the files given on the command line, or from
<tt>$stdin</tt> if no files were given, <tt>"-"</tt> is given, or after
all files have been read.

==== <tt>ARGV</tt>

Expand Down
9 changes: 7 additions & 2 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tt>"-"</tt> 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"
*/

/*
Expand Down

0 comments on commit 72772a3

Please sign in to comment.