Sha256: 8fbb113fa87f2cddbd3d8f229c125807558bb953f4581d766b8a531cdefe18cc

Contents?: true

Size: 298 Bytes

Versions: 1

Compression:

Stored size: 298 Bytes

Contents

class Array
	# Join a sequence of arguments together to form a executable command.
	def to_cmd
		collect{|v| v.to_cmd}.join(' ')
	end
end

class String
	# Conditionally quote a string if it contains whitespace or quotes.
	def to_cmd
		if match(/\s|"|'/)
			self.dump
		else
			self
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rexec-1.2.4 lib/rexec/to_cmd.rb