Avoid mutating the script argument in place
Mutating the argument in place, and in particular deleting the `:executable` entry, leads to a bug when the same code path leading to read_script_arguments is invoked twice, like in https://github.com/Homebrew/homebrew-cask/pull/139749 This commit makes a shallow copy of the argument, so that it can be safely mutated in the rest of the method.
This commit is contained in:
		
							parent
							
								
									8f419180cf
								
							
						
					
					
						commit
						f5765a73da
					
				@ -99,7 +99,12 @@ module Cask
 | 
			
		||||
        description = key ? "#{stanza} #{key.inspect}" : stanza.to_s
 | 
			
		||||
 | 
			
		||||
        # backward-compatible string value
 | 
			
		||||
        arguments = { executable: arguments } if arguments.is_a?(String)
 | 
			
		||||
        if arguments.is_a?(String)
 | 
			
		||||
          arguments = { executable: arguments }
 | 
			
		||||
        else
 | 
			
		||||
          # Avoid mutating the original argument
 | 
			
		||||
          arguments = arguments.dup
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        # key sanity
 | 
			
		||||
        permitted_keys = [:args, :input, :executable, :must_succeed, :sudo, :print_stdout, :print_stderr]
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user