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

modernize shell_out method syntax #4865

Merged
merged 4 commits into from
Apr 26, 2016
Merged

Conversation

lamont-granquist
Copy link
Contributor

**options has worked ever since we've deprecated ruby 1.9.x

**options has worked ever since we've deprecated ruby 1.9.x
@lamont-granquist
Copy link
Contributor Author

@chef/client-core trivial cleanup of ruby 1.8.7-era arguments mangling...

@danielsdeleo
Copy link
Contributor

👍

@coderanger
Copy link
Contributor

This seems like a lot of oddly duplicated code still.

@coderanger
Copy link
Contributor

      def shell_out(*args, **options)
        # For backwards compat, in case something below us modifies args?
        args = args.dup
        options = options.dup
        env_key = options.has_key?(:env) ? :env : :environment
        options[env_key] = {
            "LC_ALL" => Chef::Config[:internal_locale],
            "LANGUAGE" => Chef::Config[:internal_locale],
            "LANG" => Chef::Config[:internal_locale],
          }.update(options[env_key] || {})
        shell_out_command(*args, **options)
      end

That should be equivalent, right?

@lamont-granquist
Copy link
Contributor Author

you still have to dup options[env_key] i think

@lamont-granquist
Copy link
Contributor Author

oh wait... parsing...

@coderanger
Copy link
Contributor

I think that should be correct, it's a new hash object .update'd with the old one, should mutate the new object.

@lamont-granquist
Copy link
Contributor Author

yeah, that works the same in my head, lets see if it works the same in the tests..

@coderanger
Copy link
Contributor

We should have a comment on the args.dup one way or another, otherwise it looks unintentional since nothing in there mutates args :)

@lamont-granquist
Copy link
Contributor Author

i think it is unintentional now and can be deleted?

we only ever did this in order to mutate the options and with the
**options syntax we don't need to do this anymore.
@coderanger
Copy link
Contributor

Or that, is there anything below this in the call stack that expects to modify the args but doesn't dup itself? If there is it's a huge bug but never say never ...

@lamont-granquist
Copy link
Contributor Author

oh there's the deprecated options garbage...

@coderanger
Copy link
Contributor

Yeah, might need to fix a few more functions at the same time :-(

@lamont-granquist
Copy link
Contributor Author

yeah i got my yak trimmer out...

@lamont-granquist
Copy link
Contributor Author

actually i think this works, #run_command_compatible_options does a #dup on args itself, and mixlib-shellout doesn't mangle its own args...

@coderanger
Copy link
Contributor

👍 the deprecation code is gross but this should work I think (travis failure looks unrelated)

@lamont-granquist
Copy link
Contributor Author

yeah but the deprecation code all gets nuked from orbit, hopefully soonish, whenever we start with Chef-13. i just want to make sure that when we grep for Chef.log_deprecation we find this and nuke it.

@codecov-io
Copy link

Current coverage is 100%

Merging #4865 into master will not change coverage

@@           master   #4865   diff @@
=====================================
  Files           0       0          
  Lines           0       0          
  Methods         0       0          
  Messages        0       0          
  Branches        0       0          
=====================================
  Hits            0       0          
  Misses          0       0          
  Partials        0       0          

Sunburst

Powered by Codecov. Last updated by 1c106d6

@lamont-granquist
Copy link
Contributor Author

uh, lolwut?

@lamont-granquist lamont-granquist merged commit 82ad81d into master Apr 26, 2016
@lamont-granquist lamont-granquist deleted the lcg/shell_out_syntax branch April 26, 2016 00:01
@thommay thommay added Type: Enhancement Adds new functionality. and removed Enhancement labels Jan 25, 2017
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Enhancement Adds new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants