# Surprise? ARGVundefined after processing ARGF

**URL:** <https://www.ruby-forum.com/t/surprise-argvundefined-after-processing-argf/64109>\
**Category:** Ruby\
**Created:** [June 22, 2006, 3:21am UTC](https://www.ruby-forum.com/t/surprise-argvundefined-after-processing-argf/64109 "2006-06-22T03:21:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xmg-eric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/f04885/32.png) [@xmg-eric](https://www.ruby-forum.com/u/xmg-eric)\
**Post date:** [June 22, 2006, 3:21am UTC](https://www.ruby-forum.com/t/surprise-argvundefined-after-processing-argf/64109/1 "2006-06-22T03:21:47Z")

</div>

I found this behavior surprising. Is it  
intentional (and therefore something I need  
to understand better), or is it a bug:

```
 print_usage if ARGV[0] == nil
 puts ARGV[0] # => filename

 # Parse the document
 @doc = Document.new ARGF.read()
 puts ARGV[0] # => nil
```

---

<div class="post-metadata">

**Author:** ![xmg-eric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/f04885/32.png) [@xmg-eric](https://www.ruby-forum.com/u/xmg-eric)\
**Post date:** [June 22, 2006, 3:46am UTC](https://www.ruby-forum.com/t/surprise-argvundefined-after-processing-argf/64109/2 "2006-06-22T03:46:42Z")

</div>

Hi,

In message “Re: Surprise? ARGV[0] undefined after processing ARGF”  
on Thu, 22 Jun 2006 10:19:00 +0900, Eric A.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:  
|I found this behavior surprising. Is it  
|intentional (and therefore something I need  
|to understand better), or is it a bug:

Intentional. Processed file names are removed from ARGV to tell you  
how far you have done already.

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![xmg-eric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/f04885/32.png) [@xmg-eric](https://www.ruby-forum.com/u/xmg-eric)\
**Post date:** [June 23, 2006, 10:22pm UTC](https://www.ruby-forum.com/t/surprise-argvundefined-after-processing-argf/64109/3 "2006-06-23T22:22:32Z")

</div>

Ok.  
Thanks.
