Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #322 from funny-falcon/em_system

fix EM.system when unicode characters used
  • Loading branch information...
commit 19a8b2a0565134095958102984acd530872aa88d 2 parents c76f6f6 + f7fcf17
@tmm1 tmm1 authored
View
2  lib/em/processes.rb
@@ -114,7 +114,7 @@ def EventMachine::system cmd, *args, &cb
init = args.pop if args.last.is_a? Proc
# merge remaining arguments into the command
- cmd = ([cmd] + args.map{|a|a.to_s.dump}).join(' ')
+ cmd = [cmd, *args]
EM.get_subprocess_pid(EM.popen(cmd, SystemCmd, cb) do |c|
init[c] if init
View
7 lib/eventmachine.rb
@@ -1156,7 +1156,12 @@ def self.popen cmd, handler=nil, *args
# Perhaps misnamed since the underlying function uses socketpair and is full-duplex.
klass = klass_from_handler(Connection, handler, *args)
- w = Shellwords::shellwords( cmd )
+ w = case cmd
+ when Array
+ cmd
+ when String
+ Shellwords::shellwords( cmd )
+ end
w.unshift( w.first ) if w.first
s = invoke_popen( w )
c = klass.new s, *args
View
28 tests/test_system.rb
@@ -0,0 +1,28 @@
+# coding: utf-8
+require 'em_test_helper'
+
+class TestSystem < Test::Unit::TestCase
+ def setup
+ @filename = File.expand_path("../я манал dump.txt", __FILE__)
+ @test_data = 'a' * 100
+ File.open(@filename, 'w'){|f| f.write(@test_data)}
+ end
+
+ def test_system
+ result = nil
+ status = nil
+ EM.run {
+ EM.system('cat', @filename){|out, state|
+ result = out
+ status = state.exitstatus
+ EM.stop
+ }
+ }
+ assert_equal(0, status)
+ assert_equal(@test_data, result)
+ end
+
+ def teardown
+ File.unlink(@filename)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.