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

Opening file in read/write mode prevents use of /dev/stdout as target, unless it's the terminal #150

Open
dmolesUC opened this issue Jul 31, 2020 · 0 comments

Comments

@dmolesUC
Copy link

dmolesUC commented Jul 31, 2020

I've been trying to get db:seed:dump to write to $stdout by passing FILE=/dev/stdout. This sort of works, insofar as if I type

FILE=/dev/stdout rake db:seed:dump

in the terminal, I get the seeds dumped to the terminal. However, if I try to pipe the output to grep, redirect it to a file, or otherwise mess with it, it fails with Errno:EACCESS.

After some experimentation (see this StackOverflow question), I narrowed the issue down to this line in DumpMethods.open_io:

mode = options[:append] ? 'a+' : 'w+'

Is there a reason we need the + ("update" mode) here? I monkey-patched open_io to use plain w instead and it seems fine.

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

No branches or pull requests

1 participant