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

Open3 chdir parameter removes quoting #6565

Closed
byteit101 opened this issue Feb 17, 2021 · 5 comments
Closed

Open3 chdir parameter removes quoting #6565

byteit101 opened this issue Feb 17, 2021 · 5 comments

Comments

@byteit101
Copy link
Member

Passing quotes to Open3 are removed (and presumably parsed as multiple arguments) when using the :chdir parameter. This is different from MRI

Environment Information

JRuby 9.2 and master
Linux (Debian, x64)

Expected Behavior (MRI)

~ ruby -e "require 'open3';puts Open3.capture2('echo', '"'"hey"'"')[0];"       
"hey"
~ ruby -e "require 'open3';puts Open3.capture2('echo', '"'"hey"'"', chdir: '/')[0];"
"hey"

Actual Behavior (JRuby)

~ ruby -e "require 'open3';puts Open3.capture2('echo', '"'"hey"'"')[0];"       
"hey"
~ ruby -e "require 'open3';puts Open3.capture2('echo', '"'"hey"'"', chdir: '/')[0];"
hey

Unquoted code

require 'open3'
puts Open3.capture2('echo', '"hey"', chdir: '/')[0]
@byteit101
Copy link
Member Author

Looks like this issue is related, particularly this comment: #985 (comment)

@headius
Copy link
Member

headius commented Feb 17, 2021

Are you sure this is broken on master? This could be a platform difference, but for me on MacOS it works:

$ ruby -e "require 'open3';puts Open3.capture2('echo', '"'"hey"'"', chdir: '/')[0];"
"hey"

I would have expected this to be fixed by @mrnoname1000's clever fix from #6226, which was specifically intended to preserve quoting when we have to use sh (which is the case here because of chdir).

@byteit101
Copy link
Member Author

My bad, only on the latest released version and 2020-12-12 master. I was out of date

@headius
Copy link
Member

headius commented Feb 18, 2021

Pushed #6568 to backport the fixes to 9.2.

@headius
Copy link
Member

headius commented Feb 18, 2021

Fixed by #6568.

@headius headius closed this as completed Feb 18, 2021
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

2 participants