Skip to content
This repository

fix EM.system when unicode characters used #322

Merged
merged 1 commit into from about 1 year ago

2 participants

Sokolov Yura Aman Gupta
Sokolov Yura

Since EventMachine C++ core already use execvp, there is no need to call "dump" in EM.system. In fact, using "dump" breaks international language arguments

Aman Gupta tmm1 merged commit 19a8b2a into from February 27, 2013
Aman Gupta tmm1 closed this February 27, 2013
Aman Gupta tmm1 referenced this pull request from a commit March 08, 2013
Aman Gupta fix EM.system (cc #322) (closes #413) 16f6d94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 06, 2012
Sokolov Yura fix EM.system when unicode characters used f7fcf17
This page is out of date. Refresh to see the latest.
2  lib/em/processes.rb
@@ -114,7 +114,7 @@ def EventMachine::system cmd, *args, &cb
114 114
     init = args.pop if args.last.is_a? Proc
115 115
 
116 116
     # merge remaining arguments into the command
117  
-    cmd = ([cmd] + args.map{|a|a.to_s.dump}).join(' ')
  117
+    cmd = [cmd, *args]
118 118
 
119 119
     EM.get_subprocess_pid(EM.popen(cmd, SystemCmd, cb) do |c|
120 120
       init[c] if init
7  lib/eventmachine.rb
@@ -1156,7 +1156,12 @@ def self.popen cmd, handler=nil, *args
1156 1156
     # Perhaps misnamed since the underlying function uses socketpair and is full-duplex.
1157 1157
 
1158 1158
     klass = klass_from_handler(Connection, handler, *args)
1159  
-    w = Shellwords::shellwords( cmd )
  1159
+    w = case cmd
  1160
+        when Array
  1161
+          cmd
  1162
+        when String
  1163
+          Shellwords::shellwords( cmd )
  1164
+        end
1160 1165
     w.unshift( w.first ) if w.first
1161 1166
     s = invoke_popen( w )
1162 1167
     c = klass.new s, *args
28  tests/test_system.rb
... ...
@@ -0,0 +1,28 @@
  1
+# coding: utf-8
  2
+require 'em_test_helper'
  3
+
  4
+class TestSystem < Test::Unit::TestCase
  5
+  def setup
  6
+    @filename = File.expand_path("../я манал dump.txt", __FILE__)
  7
+    @test_data = 'a' * 100
  8
+    File.open(@filename, 'w'){|f| f.write(@test_data)}
  9
+  end
  10
+
  11
+  def test_system
  12
+    result = nil
  13
+    status = nil
  14
+    EM.run {
  15
+      EM.system('cat', @filename){|out, state|
  16
+        result = out
  17
+        status = state.exitstatus
  18
+        EM.stop
  19
+      }
  20
+    }
  21
+    assert_equal(0, status)
  22
+    assert_equal(@test_data, result)
  23
+  end
  24
+
  25
+  def teardown
  26
+    File.unlink(@filename)
  27
+  end
  28
+end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.