# Bug in ruby or bug in my brain?

**URL:** <https://www.ruby-forum.com/t/bug-in-ruby-or-bug-in-my-brain/102018>\
**Category:** Ruby\
**Created:** [August 9, 2006, 9:46am UTC](https://www.ruby-forum.com/t/bug-in-ruby-or-bug-in-my-brain/102018 "2006-08-09T09:46:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngoc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e495f1/32.png) [@ngoc](https://www.ruby-forum.com/u/ngoc)\
**Post date:** [August 9, 2006, 9:46am UTC](https://www.ruby-forum.com/t/bug-in-ruby-or-bug-in-my-brain/102018/1 "2006-08-09T09:46:24Z")

</div>

#!/usr/bin/ruby  
diff\_file = File.open(‘diff.txt’)  
diff\_file.each { |line|  
next if line =~ /^Only/  
system “dos2unix #{line.split(’ and ‘).at(1).sub(’ differ’, ‘’)}”  
}  
-\>work well

* * *

#!/usr/bin/ruby  
diff\_file = File.open(‘diff.txt’)  
diff\_file.each { |line|  
next if line =~ /^Only/  
system(“dos2unix”, line.split(’ and ‘).at(1).sub(’ differ’, ‘’))  
}  
-\>problems with converting error message

---

<div class="post-metadata">

**Author:** ![ngoc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e495f1/32.png) [@ngoc](https://www.ruby-forum.com/u/ngoc)\
**Post date:** [August 9, 2006, 10:01am UTC](https://www.ruby-forum.com/t/bug-in-ruby-or-bug-in-my-brain/102018/2 "2006-08-09T10:01:25Z")

</div>

Hi,

I don’t know but both caused an exception on my box by using random  
diff.txt file.

In message “Re: bug in ruby or bug in my brain?”  
on Wed, 9 Aug 2006 16:45:05 +0900, ngoc [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:  
|  
|#!/usr/bin/ruby  
|diff\_file = File.open(‘diff.txt’)  
|diff\_file.each { |line|  
| next if line =~ /^Only/  
| system “dos2unix #{line.split(’ and ‘).at(1).sub(’ differ’, ‘’)}”  
|}  
|-\>work well  
|  
|-------------------  
|#!/usr/bin/ruby  
|diff\_file = File.open(‘diff.txt’)  
|diff\_file.each { |line|  
| next if line =~ /^Only/  
| system(“dos2unix”, line.split(’ and ‘).at(1).sub(’ differ’, ‘’))  
|}  
|-\>problems with converting error message

---

<div class="post-metadata">

**Author:** ![ngoc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e495f1/32.png) [@ngoc](https://www.ruby-forum.com/u/ngoc)\
**Post date:** [August 9, 2006, 10:46am UTC](https://www.ruby-forum.com/t/bug-in-ruby-or-bug-in-my-brain/102018/3 "2006-08-09T10:46:27Z")

</div>

Yukihiro M. wrote:

> Hi,
> 
> I don’t know but both caused an exception on my box by using random  
> diff.txt file.  
> My box is Redhat Enterprise Workstation 3.0  
> Ruby 1.6.8 is already installed in Redhat

My diff.txt is generated when using diff command in linux.  
Its output is: Files catalogue\_1/A.txt and catalogue\_2/A.txt differ  
So I use Ruby to pick “catalogue\_2/A.txt” out of that string and convert  
the file to unix format. (A.txt from server is downloaded to a linux and  
a windows machine, after that I want to check A.txt is the same. But it  
differs because linux and windows has different ending. So I have to  
convert windows ending to unix ending).

---

<div class="post-metadata">

**Author:** ![ngoc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e495f1/32.png) [@ngoc](https://www.ruby-forum.com/u/ngoc)\
**Post date:** [August 9, 2006, 4:19pm UTC](https://www.ruby-forum.com/t/bug-in-ruby-or-bug-in-my-brain/102018/4 "2006-08-09T16:19:48Z")

</div>

Hi,

At Wed, 9 Aug 2006 16:45:05 +0900,  
ngoc wrote in [ruby-talk:207244]:

> #!/usr/bin/ruby  
> diff\_file = File.open(‘diff.txt’)  
> diff\_file.each { |line|  
> next if line =~ /^Only/  
> line.chomp!
