Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awesome_file works with closed file #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

solutus
Copy link

@solutus solutus commented Nov 11, 2013

Test case:
echo "a\nb\nc" > /tmp/test
irb
irb > File.open("/tmp/test") { |file| file.each_line { |line| puts "Got #{ line.dump }" } }

Log:
Got "a\nb\nc\n"
IOError: closed stream
from /Users/user/.rvm/gems/ruby-2.1.0-preview1/gems/awesome_print-1.2.0/lib/awesome_print/formatter.rb:199:in `directory?'

Root cause: File.directory?(f) asks closed f(ile)

It looks like it isn't necessary to do this check. If ls -d runs for file, '-d' - is ignored

@imajes
Copy link
Collaborator

imajes commented Dec 29, 2014

Can we get a test with this? I know this is crazy old but it'd be great to get this merged in!

@gerrywastaken
Copy link
Contributor

gerrywastaken commented May 12, 2016

Running the Travis build against this PR: https://travis-ci.org/gerrywastaken/awesome_print/builds/129617661

@solutus I haven't yet looked at the change, but a test would indeed be helpful.

@imajes
Copy link
Collaborator

imajes commented Nov 7, 2017

As a note, we should fix this, but ls isn't portable. We need to figure the right way to do that (wrt the recent ENV['HOME'] piece, portability is clearly more important than we might have considered!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants